@unique-nft/sdk
Advanced tools
Comparing version 0.1.11 to 0.1.12
143
index.js
import Axios from 'axios'; | ||
import { Coder } from 'abi-coder'; | ||
import FormData from 'form-data'; | ||
@@ -47,17 +48,17 @@ | ||
var __defProp = Object.defineProperty; | ||
var __defProp$2 = Object.defineProperty; | ||
var __defProps = Object.defineProperties; | ||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols; | ||
var __hasOwnProp$2 = Object.prototype.hasOwnProperty; | ||
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues$2 = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__hasOwnProp$2.call(b, prop)) | ||
__defNormalProp$2(a, prop, b[prop]); | ||
if (__getOwnPropSymbols$2) | ||
for (var prop of __getOwnPropSymbols$2(b)) { | ||
if (__propIsEnum$2.call(b, prop)) | ||
__defNormalProp$2(a, prop, b[prop]); | ||
} | ||
@@ -78,3 +79,3 @@ return a; | ||
url: this.url, | ||
params: __spreadProps(__spreadValues({}, options), { use: "BuildBatch" }), | ||
params: __spreadProps(__spreadValues$2({}, options), { use: "BuildBatch" }), | ||
data: args | ||
@@ -88,3 +89,3 @@ }); | ||
url: this.url, | ||
params: __spreadProps(__spreadValues({}, options), { use: "Build" }), | ||
params: __spreadProps(__spreadValues$2({}, options), { use: "Build" }), | ||
data: args | ||
@@ -115,3 +116,3 @@ }); | ||
url: this.url, | ||
params: __spreadProps(__spreadValues({}, options), { use: "Submit" }), | ||
params: __spreadProps(__spreadValues$2({}, options), { use: "Submit" }), | ||
data: submitTxArguments | ||
@@ -126,3 +127,3 @@ }); | ||
url: this.url, | ||
params: __spreadProps(__spreadValues({}, options), { use: "SubmitWatch" }), | ||
params: __spreadProps(__spreadValues$2({}, options), { use: "SubmitWatch" }), | ||
data: submitTxArguments | ||
@@ -215,2 +216,103 @@ }); | ||
const parseEvmEvents = (events, abi) => { | ||
const erc20Coder = new Coder(abi); | ||
const parsedEvents = []; | ||
const unknownEvents = []; | ||
events.filter((event) => event.section === "evm" && event.method === "Log").forEach((event) => { | ||
const logData = event.data[0]; | ||
const { topics, data } = logData; | ||
try { | ||
const decoded = erc20Coder.decodeEvent(topics, data); | ||
parsedEvents.push({ | ||
name: decoded.name, | ||
values: decoded.values | ||
}); | ||
} catch (err) { | ||
unknownEvents.push({ | ||
topics, | ||
data | ||
}); | ||
} | ||
}); | ||
return { | ||
parsedEvents, | ||
unknownEvents | ||
}; | ||
}; | ||
var __defProp$1 = Object.defineProperty; | ||
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols; | ||
var __hasOwnProp$1 = Object.prototype.hasOwnProperty; | ||
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues$1 = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp$1.call(b, prop)) | ||
__defNormalProp$1(a, prop, b[prop]); | ||
if (__getOwnPropSymbols$1) | ||
for (var prop of __getOwnPropSymbols$1(b)) { | ||
if (__propIsEnum$1.call(b, prop)) | ||
__defNormalProp$1(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
class ContractSendMutation extends Mutation { | ||
constructor(client, method, path, contract) { | ||
super(client, method, path); | ||
this.contract = contract; | ||
} | ||
async build(args) { | ||
return super.build(__spreadValues$1({ | ||
contractAddress: this.contract.contractAddress, | ||
abi: this.contract.abi | ||
}, args)); | ||
} | ||
async submitWaitResult(args) { | ||
const result = await super.submitWaitResult(args); | ||
const { parsedEvents, unknownEvents } = parseEvmEvents(result.events, this.contract.abi); | ||
result.parsed.parsedEvents = parsedEvents; | ||
result.parsed.unknownEvents = unknownEvents; | ||
return result; | ||
} | ||
} | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
class Contract extends Section { | ||
constructor(client, contractAddress, abi) { | ||
super(client); | ||
this.contractAddress = contractAddress; | ||
this.abi = abi; | ||
this.path = "evm"; | ||
this.baseUrl = `${this.client.options.baseUrl}/${this.path}`; | ||
this.send = new ContractSendMutation(this.client, Method.POST, `${this.path}/send`, this); | ||
} | ||
async call(args) { | ||
const response = await this.client.instance({ | ||
method: Method.POST, | ||
baseURL: this.baseUrl, | ||
url: "call", | ||
data: __spreadValues({ | ||
contractAddress: this.contractAddress, | ||
abi: this.abi | ||
}, args) | ||
}); | ||
return response.data; | ||
} | ||
} | ||
class Evm extends Section { | ||
@@ -225,2 +327,9 @@ constructor() { | ||
} | ||
async contractConnect(contractAddress, abi) { | ||
const { exists } = await this.contractExists({ contractAddress }); | ||
if (!exists) { | ||
throw new Error("Contract is not exists"); | ||
} | ||
return new Contract(this.client, contractAddress, abi); | ||
} | ||
} | ||
@@ -405,3 +514,3 @@ | ||
var version = "0.1.11"; | ||
var version = "0.1.12"; | ||
@@ -408,0 +517,0 @@ class Common extends Section { |
{ | ||
"name": "@unique-nft/sdk", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"license": "MIT", | ||
"dependencies": { | ||
"abi-coder": "^4.1.1", | ||
"axios": "^0.27.2", | ||
@@ -7,0 +8,0 @@ "form-data": "^4.0.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
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
112304
3259
3
+ Addedabi-coder@^4.1.1
+ Added@ethersproject/abi@5.7.0(transitive)
+ Added@ethersproject/abstract-provider@5.7.0(transitive)
+ Added@ethersproject/abstract-signer@5.7.0(transitive)
+ Added@ethersproject/address@5.7.0(transitive)
+ Added@ethersproject/base64@5.7.0(transitive)
+ Added@ethersproject/bignumber@5.7.0(transitive)
+ Added@ethersproject/bytes@5.7.0(transitive)
+ Added@ethersproject/constants@5.7.0(transitive)
+ Added@ethersproject/hash@5.7.0(transitive)
+ Added@ethersproject/keccak256@5.7.0(transitive)
+ Added@ethersproject/logger@5.7.0(transitive)
+ Added@ethersproject/networks@5.7.1(transitive)
+ Added@ethersproject/properties@5.7.0(transitive)
+ Added@ethersproject/rlp@5.7.0(transitive)
+ Added@ethersproject/signing-key@5.7.0(transitive)
+ Added@ethersproject/strings@5.7.0(transitive)
+ Added@ethersproject/transactions@5.7.0(transitive)
+ Added@ethersproject/web@5.7.1(transitive)
+ Addedabi-coder@4.1.1(transitive)
+ Addedbn.js@4.12.15.2.1(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedelliptic@6.5.4(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjs-sha3@0.8.0(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)