@reservoir0x/reservoir-sdk
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -104,3 +104,3 @@ var $lPQI4$etherslibutils = require("ethers/lib/utils"); | ||
var $134f7602d1733f79$exports = {}; | ||
$134f7602d1733f79$exports = JSON.parse('{"name":"@reservoir0x/reservoir-sdk","version":"0.7.2","description":"An SDK that can be used in any javascript/typescript context to easily interact with Reservoir liquidity APIs","source":"src/index.ts","main":"dist/index.js","module":"dist/index.module.js","types":"dist/index.d.ts","author":"Reservoir Protocol","license":"MIT","files":["dist"],"scripts":{"clean":"rm -rf dist","version":"yarn version","version:package":"sh ../../scripts/package-version.sh","version:update":"yarn version ${0}; PACKAGE_VERSION=$(yarn version:package); git add -A; git commit -m \\"\uD83C\uDF89 Release client package v$PACKAGE_VERSION\\"; git tag v${PACKAGE_VERSION}-SDK; git push --tags;","syncApi":"node ./sync-api.mjs","changelog":"node ../../scripts/generate-changelog.js package=sdk"},"repository":{"type":"git","url":"https://github.com/reservoirprotocol/reservoir-kit"},"sideEffects":false,"keywords":["nft","reservoir","reservoir-sdk","reservoirkit","protocol","sdk"],"peerDependencies":{"ethers":"^5.6.1"},"dependencies":{"axios":"^0.27.2"},"publishConfig":{"access":"public"},"devDependencies":{"openapi-typescript":"^5.4.1"}}'); | ||
$134f7602d1733f79$exports = JSON.parse('{"name":"@reservoir0x/reservoir-sdk","version":"0.7.3","description":"An SDK that can be used in any javascript/typescript context to easily interact with Reservoir liquidity APIs","source":"src/index.ts","main":"dist/index.js","module":"dist/index.module.js","types":"dist/index.d.ts","author":"Reservoir Protocol","license":"MIT","files":["dist"],"scripts":{"clean":"rm -rf dist","version":"yarn version","version:package":"sh ../../scripts/package-version.sh","version:update":"yarn version ${0}; PACKAGE_VERSION=$(yarn version:package); git add -A; git commit -m \\"\uD83C\uDF89 Release client package v$PACKAGE_VERSION\\"; git tag v${PACKAGE_VERSION}-SDK; git push --tags;","syncApi":"node ./sync-api.mjs","changelog":"node ../../scripts/generate-changelog.js package=sdk"},"repository":{"type":"git","url":"https://github.com/reservoirprotocol/reservoir-kit"},"sideEffects":false,"keywords":["nft","reservoir","reservoir-sdk","reservoirkit","protocol","sdk"],"peerDependencies":{"ethers":"^5.6.1"},"dependencies":{"axios":"^0.27.2"},"publishConfig":{"access":"public"},"devDependencies":{"openapi-typescript":"^5.4.1"}}'); | ||
@@ -142,3 +142,3 @@ | ||
async function $350ec40f38382016$export$21ece85d7636deb(request, signer, setState, newJson, expectedPrice) { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
const client = (0, $3ba04d43fdd1e5a5$export$6bb76d6eba7e258c)(); | ||
@@ -227,3 +227,3 @@ try { | ||
const step = json.steps[incompleteStepIndex]; | ||
const stepItems = json.steps[incompleteStepIndex].items; | ||
let stepItems = json.steps[incompleteStepIndex].items; | ||
if (!stepItems) { | ||
@@ -254,2 +254,3 @@ client.log([ | ||
if (!items || !items[incompleteStepItemIndex] || !items[incompleteStepItemIndex].data) throw json; | ||
stepItems = items; | ||
stepItem = items[incompleteStepItemIndex]; | ||
@@ -260,147 +261,158 @@ setState([ | ||
} | ||
const stepData = stepItem.data; | ||
// Handle each step based on it's kind | ||
switch(kind){ | ||
// Make an on-chain transaction | ||
case "transaction": | ||
{ | ||
client.log([ | ||
"Execute Steps: Begin transaction step, sending transaction" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
const tx = await signer.sendTransaction(stepData); | ||
if ((_c = json.steps[incompleteStepIndex].items) === null || _c === void 0 ? void 0 : _c[incompleteStepItemIndex]) stepItem.txHash = tx.hash; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
client.log([ | ||
"Execute Steps: Transaction step, waiting on transaction" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
await tx.wait(); | ||
client.log([ | ||
"Execute Steps: Transaction finished, starting to poll for confirmation" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
//Implicitly poll the confirmation url to confirm the transaction went through | ||
const confirmationUrl = new URL(`${request.baseURL}/transactions/${tx.hash}/synced/v1`); | ||
const headers = { | ||
"x-rkc-version": (0, $134f7602d1733f79$exports.version) | ||
}; | ||
if (request.headers && request.headers["x-api-key"]) headers["x-api-key"] = request.headers["x-api-key"]; | ||
if (client === null || client === void 0 ? void 0 : client.uiVersion) request.headers["x-rkui-version"] = client.uiVersion; | ||
await (0, $8f16fb6674bc87a2$export$d2c70568ef790b87)({ | ||
url: confirmationUrl.href, | ||
method: "get", | ||
headers: headers | ||
}, (res)=>{ | ||
client.log([ | ||
"Execute Steps: Polling for confirmation", | ||
res | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
return res && res.data.synced; | ||
}); | ||
if (json.steps.slice(incompleteStepIndex + 1).findIndex((step)=>step.kind === "transaction") === -1) //Confirm that on-chain tx has been picked up by the indexer for the last transaction | ||
{ | ||
if (stepItem.txHash && (isSell || isBuy)) { | ||
client.log([ | ||
"Execute Steps: Polling sales to verify transaction was indexed" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
const indexerConfirmationUrl = new URL(`${request.baseURL}/sales/v3`); | ||
const queryParams = { | ||
txHash: stepItem.txHash | ||
}; | ||
(0, $0fd5f57dc6013621$export$dc1827290674c112)(indexerConfirmationUrl, queryParams); | ||
await (0, $8f16fb6674bc87a2$export$d2c70568ef790b87)({ | ||
url: indexerConfirmationUrl.href, | ||
method: "get", | ||
headers: headers | ||
}, (res)=>{ | ||
client.log([ | ||
`Execute Steps: Begin processing step items for: ${step.action}` | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
const promises = stepItems.filter((stepItem)=>stepItem.status === "incomplete").map((stepItem)=>{ | ||
return new Promise(async (resolve, reject)=>{ | ||
try { | ||
const stepData = stepItem.data; | ||
if (!json) return; | ||
// Handle each step based on it's kind | ||
switch(kind){ | ||
// Make an on-chain transaction | ||
case "transaction": | ||
{ | ||
client.log([ | ||
"Execute Steps: Polling sales to check if indexed", | ||
res | ||
"Execute Steps: Begin transaction step for, sending transaction" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
if (res.status === 200) { | ||
const data = res.data; | ||
return data.sales && data.sales.length > 0 ? true : false; | ||
} | ||
return false; | ||
}); | ||
} | ||
} | ||
break; | ||
} | ||
// Sign a message | ||
case "signature": | ||
{ | ||
let signature; | ||
const signData = stepData["sign"]; | ||
const postData = stepData["post"]; | ||
client.log([ | ||
"Execute Steps: Begin signature step" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
if (signData) { | ||
// Request user signature | ||
if (signData.signatureKind === "eip191") { | ||
client.log([ | ||
"Execute Steps: Signing with eip191" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
if (signData.message.match(/0x[0-9a-fA-F]{64}/)) // If the message represents a hash, we need to convert it to raw bytes first | ||
signature = await signer.signMessage((0, $lPQI4$etherslibutils.arrayify)(signData.message)); | ||
else signature = await signer.signMessage(signData.message); | ||
} else if (signData.signatureKind === "eip712") { | ||
client.log([ | ||
"Execute Steps: Signing with eip712" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
signature = await signer._signTypedData(signData.domain, signData.types, signData.value); | ||
} | ||
if (signature) request.params = { | ||
...request.params, | ||
signature: signature | ||
}; | ||
} | ||
if (postData) { | ||
client.log([ | ||
"Execute Steps: Posting order" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
const postOrderUrl = new URL(`${request.baseURL}${postData.endpoint}`); | ||
try { | ||
const getData = async function() { | ||
const tx = await signer.sendTransaction(stepData); | ||
stepItem.txHash = tx.hash; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
client.log([ | ||
"Execute Steps: Transaction step, waiting on transaction" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
await tx.wait(); | ||
client.log([ | ||
"Execute Steps: Transaction finished, starting to poll for confirmation" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
//Implicitly poll the confirmation url to confirm the transaction went through | ||
const confirmationUrl = new URL(`${request.baseURL}/transactions/${tx.hash}/synced/v1`); | ||
const headers = { | ||
"Content-Type": "application/json", | ||
"x-rkc-version": (0, $134f7602d1733f79$exports.version) | ||
}; | ||
if (request.headers && request.headers["x-api-key"]) headers["x-api-key"] = request.headers["x-api-key"]; | ||
let response = await (0, ($parcel$interopDefault($lPQI4$axios))).post(postOrderUrl.href, JSON.stringify(postData.body), { | ||
method: postData.method, | ||
headers: headers, | ||
params: request.params | ||
if (request.headers && (client === null || client === void 0 ? void 0 : client.uiVersion)) request.headers["x-rkui-version"] = client.uiVersion; | ||
await (0, $8f16fb6674bc87a2$export$d2c70568ef790b87)({ | ||
url: confirmationUrl.href, | ||
method: "get", | ||
headers: headers | ||
}, (res)=>{ | ||
client.log([ | ||
"Execute Steps: Polling for confirmation", | ||
res | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
return res && res.data.synced; | ||
}); | ||
return response; | ||
}; | ||
const res = await getData(); | ||
if (res.status > 299 || res.status < 200) throw res.data; | ||
if (res.data.results) stepItem.orderData = res.data.results; | ||
else if (res.data && res.data.orderId) stepItem.orderData = [ | ||
{ | ||
orderId: res.data.orderId, | ||
crossPostingOrderId: res.data.crossPostingOrderId, | ||
orderIndex: res.data.orderIndex || 0 | ||
//Confirm that on-chain tx has been picked up by the indexer | ||
if (stepItem.txHash && (isSell || isBuy)) { | ||
client.log([ | ||
"Execute Steps: Polling sales to verify transaction was indexed" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
const indexerConfirmationUrl = new URL(`${request.baseURL}/sales/v4`); | ||
const queryParams = { | ||
txHash: stepItem.txHash | ||
}; | ||
(0, $0fd5f57dc6013621$export$dc1827290674c112)(indexerConfirmationUrl, queryParams); | ||
await (0, $8f16fb6674bc87a2$export$d2c70568ef790b87)({ | ||
url: indexerConfirmationUrl.href, | ||
method: "get", | ||
headers: headers | ||
}, (res)=>{ | ||
client.log([ | ||
"Execute Steps: Polling sales to check if indexed", | ||
res | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
if (res.status === 200) { | ||
const data = res.data; | ||
return data.sales && data.sales.length > 0 ? true : false; | ||
} | ||
return false; | ||
}); | ||
} | ||
]; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
} catch (err) { | ||
json.steps[incompleteStepIndex].error = "Your order could not be posted."; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
throw err; | ||
} | ||
break; | ||
} | ||
// Sign a message | ||
case "signature": | ||
{ | ||
let signature; | ||
const signData = stepData["sign"]; | ||
const postData = stepData["post"]; | ||
client.log([ | ||
"Execute Steps: Begin signature step" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
if (signData) { | ||
// Request user signature | ||
if (signData.signatureKind === "eip191") { | ||
client.log([ | ||
"Execute Steps: Signing with eip191" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
if (signData.message.match(/0x[0-9a-fA-F]{64}/)) // If the message represents a hash, we need to convert it to raw bytes first | ||
signature = await signer.signMessage((0, $lPQI4$etherslibutils.arrayify)(signData.message)); | ||
else signature = await signer.signMessage(signData.message); | ||
} else if (signData.signatureKind === "eip712") { | ||
client.log([ | ||
"Execute Steps: Signing with eip712" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
signature = await signer._signTypedData(signData.domain, signData.types, signData.value); | ||
} | ||
if (signature) request.params = { | ||
...request.params, | ||
signature: signature | ||
}; | ||
} | ||
if (postData) { | ||
client.log([ | ||
"Execute Steps: Posting order" | ||
], (0, $b747246cb5dd2c78$export$243e62d78d3b544d).Verbose); | ||
const postOrderUrl = new URL(`${request.baseURL}${postData.endpoint}`); | ||
try { | ||
const getData = async function() { | ||
const headers = { | ||
"Content-Type": "application/json", | ||
"x-rkc-version": (0, $134f7602d1733f79$exports.version) | ||
}; | ||
if (request.headers && request.headers["x-api-key"]) headers["x-api-key"] = request.headers["x-api-key"]; | ||
let response = await (0, ($parcel$interopDefault($lPQI4$axios))).post(postOrderUrl.href, JSON.stringify(postData.body), { | ||
method: postData.method, | ||
headers: headers, | ||
params: request.params | ||
}); | ||
return response; | ||
}; | ||
const res = await getData(); | ||
if (res.status > 299 || res.status < 200) throw res.data; | ||
if (res.data.results) stepItem.orderData = res.data.results; | ||
else if (res.data && res.data.orderId) stepItem.orderData = [ | ||
{ | ||
orderId: res.data.orderId, | ||
crossPostingOrderId: res.data.crossPostingOrderId, | ||
orderIndex: res.data.orderIndex || 0 | ||
} | ||
]; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
} catch (err) { | ||
json.steps[incompleteStepIndex].error = "Your order could not be posted."; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
throw err; | ||
} | ||
} | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
break; | ||
stepItem.status = "complete"; | ||
resolve(stepItem); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
default: | ||
break; | ||
} | ||
delete step.message; | ||
stepItem.status = "complete"; | ||
}); | ||
}); | ||
await Promise.all(promises); | ||
// Recursively call executeSteps() | ||
@@ -407,0 +419,0 @@ await $350ec40f38382016$export$21ece85d7636deb(request, signer, setState, json); |
@@ -101,3 +101,3 @@ import {arrayify as $9C8uf$arrayify} from "ethers/lib/utils"; | ||
var $d3dd819ecb91ce83$exports = {}; | ||
$d3dd819ecb91ce83$exports = JSON.parse('{"name":"@reservoir0x/reservoir-sdk","version":"0.7.2","description":"An SDK that can be used in any javascript/typescript context to easily interact with Reservoir liquidity APIs","source":"src/index.ts","main":"dist/index.js","module":"dist/index.module.js","types":"dist/index.d.ts","author":"Reservoir Protocol","license":"MIT","files":["dist"],"scripts":{"clean":"rm -rf dist","version":"yarn version","version:package":"sh ../../scripts/package-version.sh","version:update":"yarn version ${0}; PACKAGE_VERSION=$(yarn version:package); git add -A; git commit -m \\"\uD83C\uDF89 Release client package v$PACKAGE_VERSION\\"; git tag v${PACKAGE_VERSION}-SDK; git push --tags;","syncApi":"node ./sync-api.mjs","changelog":"node ../../scripts/generate-changelog.js package=sdk"},"repository":{"type":"git","url":"https://github.com/reservoirprotocol/reservoir-kit"},"sideEffects":false,"keywords":["nft","reservoir","reservoir-sdk","reservoirkit","protocol","sdk"],"peerDependencies":{"ethers":"^5.6.1"},"dependencies":{"axios":"^0.27.2"},"publishConfig":{"access":"public"},"devDependencies":{"openapi-typescript":"^5.4.1"}}'); | ||
$d3dd819ecb91ce83$exports = JSON.parse('{"name":"@reservoir0x/reservoir-sdk","version":"0.7.3","description":"An SDK that can be used in any javascript/typescript context to easily interact with Reservoir liquidity APIs","source":"src/index.ts","main":"dist/index.js","module":"dist/index.module.js","types":"dist/index.d.ts","author":"Reservoir Protocol","license":"MIT","files":["dist"],"scripts":{"clean":"rm -rf dist","version":"yarn version","version:package":"sh ../../scripts/package-version.sh","version:update":"yarn version ${0}; PACKAGE_VERSION=$(yarn version:package); git add -A; git commit -m \\"\uD83C\uDF89 Release client package v$PACKAGE_VERSION\\"; git tag v${PACKAGE_VERSION}-SDK; git push --tags;","syncApi":"node ./sync-api.mjs","changelog":"node ../../scripts/generate-changelog.js package=sdk"},"repository":{"type":"git","url":"https://github.com/reservoirprotocol/reservoir-kit"},"sideEffects":false,"keywords":["nft","reservoir","reservoir-sdk","reservoirkit","protocol","sdk"],"peerDependencies":{"ethers":"^5.6.1"},"dependencies":{"axios":"^0.27.2"},"publishConfig":{"access":"public"},"devDependencies":{"openapi-typescript":"^5.4.1"}}'); | ||
@@ -139,3 +139,3 @@ | ||
async function $13b5a8bc45044506$export$21ece85d7636deb(request, signer, setState, newJson, expectedPrice) { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
const client = (0, $6496f8ee40d0c4eb$export$6bb76d6eba7e258c)(); | ||
@@ -224,3 +224,3 @@ try { | ||
const step = json.steps[incompleteStepIndex]; | ||
const stepItems = json.steps[incompleteStepIndex].items; | ||
let stepItems = json.steps[incompleteStepIndex].items; | ||
if (!stepItems) { | ||
@@ -251,2 +251,3 @@ client.log([ | ||
if (!items || !items[incompleteStepItemIndex] || !items[incompleteStepItemIndex].data) throw json; | ||
stepItems = items; | ||
stepItem = items[incompleteStepItemIndex]; | ||
@@ -257,147 +258,158 @@ setState([ | ||
} | ||
const stepData = stepItem.data; | ||
// Handle each step based on it's kind | ||
switch(kind){ | ||
// Make an on-chain transaction | ||
case "transaction": | ||
{ | ||
client.log([ | ||
"Execute Steps: Begin transaction step, sending transaction" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
const tx = await signer.sendTransaction(stepData); | ||
if ((_c = json.steps[incompleteStepIndex].items) === null || _c === void 0 ? void 0 : _c[incompleteStepItemIndex]) stepItem.txHash = tx.hash; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
client.log([ | ||
"Execute Steps: Transaction step, waiting on transaction" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
await tx.wait(); | ||
client.log([ | ||
"Execute Steps: Transaction finished, starting to poll for confirmation" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
//Implicitly poll the confirmation url to confirm the transaction went through | ||
const confirmationUrl = new URL(`${request.baseURL}/transactions/${tx.hash}/synced/v1`); | ||
const headers = { | ||
"x-rkc-version": (0, $d3dd819ecb91ce83$exports.version) | ||
}; | ||
if (request.headers && request.headers["x-api-key"]) headers["x-api-key"] = request.headers["x-api-key"]; | ||
if (client === null || client === void 0 ? void 0 : client.uiVersion) request.headers["x-rkui-version"] = client.uiVersion; | ||
await (0, $8b98f6fc3beebe05$export$d2c70568ef790b87)({ | ||
url: confirmationUrl.href, | ||
method: "get", | ||
headers: headers | ||
}, (res)=>{ | ||
client.log([ | ||
"Execute Steps: Polling for confirmation", | ||
res | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
return res && res.data.synced; | ||
}); | ||
if (json.steps.slice(incompleteStepIndex + 1).findIndex((step)=>step.kind === "transaction") === -1) //Confirm that on-chain tx has been picked up by the indexer for the last transaction | ||
{ | ||
if (stepItem.txHash && (isSell || isBuy)) { | ||
client.log([ | ||
"Execute Steps: Polling sales to verify transaction was indexed" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
const indexerConfirmationUrl = new URL(`${request.baseURL}/sales/v3`); | ||
const queryParams = { | ||
txHash: stepItem.txHash | ||
}; | ||
(0, $3d06f0c5a9f29ddf$export$dc1827290674c112)(indexerConfirmationUrl, queryParams); | ||
await (0, $8b98f6fc3beebe05$export$d2c70568ef790b87)({ | ||
url: indexerConfirmationUrl.href, | ||
method: "get", | ||
headers: headers | ||
}, (res)=>{ | ||
client.log([ | ||
`Execute Steps: Begin processing step items for: ${step.action}` | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
const promises = stepItems.filter((stepItem)=>stepItem.status === "incomplete").map((stepItem)=>{ | ||
return new Promise(async (resolve, reject)=>{ | ||
try { | ||
const stepData = stepItem.data; | ||
if (!json) return; | ||
// Handle each step based on it's kind | ||
switch(kind){ | ||
// Make an on-chain transaction | ||
case "transaction": | ||
{ | ||
client.log([ | ||
"Execute Steps: Polling sales to check if indexed", | ||
res | ||
"Execute Steps: Begin transaction step for, sending transaction" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
if (res.status === 200) { | ||
const data = res.data; | ||
return data.sales && data.sales.length > 0 ? true : false; | ||
} | ||
return false; | ||
}); | ||
} | ||
} | ||
break; | ||
} | ||
// Sign a message | ||
case "signature": | ||
{ | ||
let signature; | ||
const signData = stepData["sign"]; | ||
const postData = stepData["post"]; | ||
client.log([ | ||
"Execute Steps: Begin signature step" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
if (signData) { | ||
// Request user signature | ||
if (signData.signatureKind === "eip191") { | ||
client.log([ | ||
"Execute Steps: Signing with eip191" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
if (signData.message.match(/0x[0-9a-fA-F]{64}/)) // If the message represents a hash, we need to convert it to raw bytes first | ||
signature = await signer.signMessage((0, $9C8uf$arrayify)(signData.message)); | ||
else signature = await signer.signMessage(signData.message); | ||
} else if (signData.signatureKind === "eip712") { | ||
client.log([ | ||
"Execute Steps: Signing with eip712" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
signature = await signer._signTypedData(signData.domain, signData.types, signData.value); | ||
} | ||
if (signature) request.params = { | ||
...request.params, | ||
signature: signature | ||
}; | ||
} | ||
if (postData) { | ||
client.log([ | ||
"Execute Steps: Posting order" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
const postOrderUrl = new URL(`${request.baseURL}${postData.endpoint}`); | ||
try { | ||
const getData = async function() { | ||
const tx = await signer.sendTransaction(stepData); | ||
stepItem.txHash = tx.hash; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
client.log([ | ||
"Execute Steps: Transaction step, waiting on transaction" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
await tx.wait(); | ||
client.log([ | ||
"Execute Steps: Transaction finished, starting to poll for confirmation" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
//Implicitly poll the confirmation url to confirm the transaction went through | ||
const confirmationUrl = new URL(`${request.baseURL}/transactions/${tx.hash}/synced/v1`); | ||
const headers = { | ||
"Content-Type": "application/json", | ||
"x-rkc-version": (0, $d3dd819ecb91ce83$exports.version) | ||
}; | ||
if (request.headers && request.headers["x-api-key"]) headers["x-api-key"] = request.headers["x-api-key"]; | ||
let response = await (0, $9C8uf$axios).post(postOrderUrl.href, JSON.stringify(postData.body), { | ||
method: postData.method, | ||
headers: headers, | ||
params: request.params | ||
if (request.headers && (client === null || client === void 0 ? void 0 : client.uiVersion)) request.headers["x-rkui-version"] = client.uiVersion; | ||
await (0, $8b98f6fc3beebe05$export$d2c70568ef790b87)({ | ||
url: confirmationUrl.href, | ||
method: "get", | ||
headers: headers | ||
}, (res)=>{ | ||
client.log([ | ||
"Execute Steps: Polling for confirmation", | ||
res | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
return res && res.data.synced; | ||
}); | ||
return response; | ||
}; | ||
const res = await getData(); | ||
if (res.status > 299 || res.status < 200) throw res.data; | ||
if (res.data.results) stepItem.orderData = res.data.results; | ||
else if (res.data && res.data.orderId) stepItem.orderData = [ | ||
{ | ||
orderId: res.data.orderId, | ||
crossPostingOrderId: res.data.crossPostingOrderId, | ||
orderIndex: res.data.orderIndex || 0 | ||
//Confirm that on-chain tx has been picked up by the indexer | ||
if (stepItem.txHash && (isSell || isBuy)) { | ||
client.log([ | ||
"Execute Steps: Polling sales to verify transaction was indexed" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
const indexerConfirmationUrl = new URL(`${request.baseURL}/sales/v4`); | ||
const queryParams = { | ||
txHash: stepItem.txHash | ||
}; | ||
(0, $3d06f0c5a9f29ddf$export$dc1827290674c112)(indexerConfirmationUrl, queryParams); | ||
await (0, $8b98f6fc3beebe05$export$d2c70568ef790b87)({ | ||
url: indexerConfirmationUrl.href, | ||
method: "get", | ||
headers: headers | ||
}, (res)=>{ | ||
client.log([ | ||
"Execute Steps: Polling sales to check if indexed", | ||
res | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
if (res.status === 200) { | ||
const data = res.data; | ||
return data.sales && data.sales.length > 0 ? true : false; | ||
} | ||
return false; | ||
}); | ||
} | ||
]; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
} catch (err) { | ||
json.steps[incompleteStepIndex].error = "Your order could not be posted."; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
throw err; | ||
} | ||
break; | ||
} | ||
// Sign a message | ||
case "signature": | ||
{ | ||
let signature; | ||
const signData = stepData["sign"]; | ||
const postData = stepData["post"]; | ||
client.log([ | ||
"Execute Steps: Begin signature step" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
if (signData) { | ||
// Request user signature | ||
if (signData.signatureKind === "eip191") { | ||
client.log([ | ||
"Execute Steps: Signing with eip191" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
if (signData.message.match(/0x[0-9a-fA-F]{64}/)) // If the message represents a hash, we need to convert it to raw bytes first | ||
signature = await signer.signMessage((0, $9C8uf$arrayify)(signData.message)); | ||
else signature = await signer.signMessage(signData.message); | ||
} else if (signData.signatureKind === "eip712") { | ||
client.log([ | ||
"Execute Steps: Signing with eip712" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
signature = await signer._signTypedData(signData.domain, signData.types, signData.value); | ||
} | ||
if (signature) request.params = { | ||
...request.params, | ||
signature: signature | ||
}; | ||
} | ||
if (postData) { | ||
client.log([ | ||
"Execute Steps: Posting order" | ||
], (0, $e1b436840b45b1d8$export$243e62d78d3b544d).Verbose); | ||
const postOrderUrl = new URL(`${request.baseURL}${postData.endpoint}`); | ||
try { | ||
const getData = async function() { | ||
const headers = { | ||
"Content-Type": "application/json", | ||
"x-rkc-version": (0, $d3dd819ecb91ce83$exports.version) | ||
}; | ||
if (request.headers && request.headers["x-api-key"]) headers["x-api-key"] = request.headers["x-api-key"]; | ||
let response = await (0, $9C8uf$axios).post(postOrderUrl.href, JSON.stringify(postData.body), { | ||
method: postData.method, | ||
headers: headers, | ||
params: request.params | ||
}); | ||
return response; | ||
}; | ||
const res = await getData(); | ||
if (res.status > 299 || res.status < 200) throw res.data; | ||
if (res.data.results) stepItem.orderData = res.data.results; | ||
else if (res.data && res.data.orderId) stepItem.orderData = [ | ||
{ | ||
orderId: res.data.orderId, | ||
crossPostingOrderId: res.data.crossPostingOrderId, | ||
orderIndex: res.data.orderIndex || 0 | ||
} | ||
]; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
} catch (err) { | ||
json.steps[incompleteStepIndex].error = "Your order could not be posted."; | ||
setState([ | ||
...json === null || json === void 0 ? void 0 : json.steps | ||
]); | ||
throw err; | ||
} | ||
} | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
break; | ||
stepItem.status = "complete"; | ||
resolve(stepItem); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
default: | ||
break; | ||
} | ||
delete step.message; | ||
stepItem.status = "complete"; | ||
}); | ||
}); | ||
await Promise.all(promises); | ||
// Recursively call executeSteps() | ||
@@ -404,0 +416,0 @@ await $13b5a8bc45044506$export$21ece85d7636deb(request, signer, setState, json); |
{ | ||
"name": "@reservoir0x/reservoir-sdk", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "An SDK that can be used in any javascript/typescript context to easily interact with Reservoir liquidity APIs", | ||
@@ -5,0 +5,0 @@ "source": "src/index.ts", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1551883
11846