@kynesyslabs/demosdk 2.3.19 → 2.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/types/blockchain/Transaction.d.ts +4 -3
- package/build/types/blockchain/Transaction.js.map +1 -1
- package/build/types/blockchain/TransactionSubtypes/ContractCallTransaction.d.ts +24 -0
- package/build/types/blockchain/TransactionSubtypes/{SmartContractTransaction.js → ContractCallTransaction.js} +1 -1
- package/build/types/blockchain/TransactionSubtypes/ContractCallTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/ContractDeployTransaction.d.ts +31 -0
- package/build/types/blockchain/TransactionSubtypes/ContractDeployTransaction.js +3 -0
- package/build/types/blockchain/TransactionSubtypes/ContractDeployTransaction.js.map +1 -0
- package/build/types/blockchain/TransactionSubtypes/index.d.ts +5 -1
- package/build/types/blockchain/TransactionSubtypes/index.js +2 -0
- package/build/types/blockchain/TransactionSubtypes/index.js.map +1 -1
- package/build/types/web2/index.d.ts +3 -2
- package/build/types/web2/index.js.map +1 -1
- package/build/websdk/Web2Calls.js +37 -5
- package/build/websdk/Web2Calls.js.map +1 -1
- package/build/websdk/utils/canonicalJson.d.ts +3 -0
- package/build/websdk/utils/canonicalJson.js +68 -0
- package/build/websdk/utils/canonicalJson.js.map +1 -0
- package/package.json +3 -2
- package/build/types/blockchain/TransactionSubtypes/SmartContractTransaction.d.ts +0 -9
- package/build/types/blockchain/TransactionSubtypes/SmartContractTransaction.js.map +0 -1
|
@@ -11,10 +11,11 @@ import { BridgeOperationCompiled } from "../../bridge/nativeBridgeTypes";
|
|
|
11
11
|
import { L2PSEncryptedPayload } from "../../l2ps";
|
|
12
12
|
import { StoragePayload } from "./TransactionSubtypes/StorageTransaction";
|
|
13
13
|
import { L2PSHashPayload } from "./TransactionSubtypes/L2PSHashTransaction";
|
|
14
|
-
import {
|
|
15
|
-
|
|
14
|
+
import { ContractDeployPayload } from "./TransactionSubtypes/ContractDeployTransaction";
|
|
15
|
+
import { ContractCallPayload } from "./TransactionSubtypes/ContractCallTransaction";
|
|
16
|
+
export type TransactionContentData = ["web2Request", IWeb2Payload] | ["crosschainOperation", XMScript] | ["native", INativePayload] | ["demoswork", DemoScript] | ["l2psEncryptedTx", L2PSEncryptedPayload] | ["identity", IdentityPayload] | ["instantMessaging", InstantMessagingPayload] | ["nativeBridge", BridgeOperationCompiled] | ["storage", StoragePayload] | ["l2ps_hash_update", L2PSHashPayload] | ["contractDeploy", ContractDeployPayload] | ["contractCall", ContractCallPayload];
|
|
16
17
|
export interface TransactionContent {
|
|
17
|
-
type: "web2Request" | "crosschainOperation" | "subnet" | "native" | "demoswork" | "genesis" | "NODE_ONLINE" | "identity" | "instantMessaging" | "nativeBridge" | "l2psEncryptedTx" | "storage" | "l2ps_hash_update" | "
|
|
18
|
+
type: "web2Request" | "crosschainOperation" | "subnet" | "native" | "demoswork" | "genesis" | "NODE_ONLINE" | "identity" | "instantMessaging" | "nativeBridge" | "l2psEncryptedTx" | "storage" | "l2ps_hash_update" | "contractDeploy" | "contractCall";
|
|
18
19
|
from: string;
|
|
19
20
|
from_ed25519_address: string;
|
|
20
21
|
to: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAqFA,uCAAuC;AACvC,wDAAqC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Transaction, TransactionContent } from "../Transaction";
|
|
2
|
+
/**
|
|
3
|
+
* Payload for contract method call transactions
|
|
4
|
+
*/
|
|
5
|
+
export interface ContractCallPayload {
|
|
6
|
+
contractAddress: string;
|
|
7
|
+
method: string;
|
|
8
|
+
args: any[];
|
|
9
|
+
value?: bigint;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Transaction content type for contract call operations
|
|
13
|
+
*/
|
|
14
|
+
export type ContractCallTransactionContent = Omit<TransactionContent, 'type' | 'data'> & {
|
|
15
|
+
type: 'contractCall';
|
|
16
|
+
data: ['contractCall', ContractCallPayload];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Complete contract call transaction interface
|
|
20
|
+
*/
|
|
21
|
+
export interface ContractCallTransaction extends Omit<Transaction, 'content'> {
|
|
22
|
+
content: ContractCallTransactionContent;
|
|
23
|
+
}
|
|
24
|
+
export default ContractCallTransaction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractCallTransaction.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/ContractCallTransaction.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Transaction, TransactionContent } from "../Transaction";
|
|
2
|
+
/**
|
|
3
|
+
* Contract metadata for deployment
|
|
4
|
+
*/
|
|
5
|
+
export interface ContractMetadata {
|
|
6
|
+
name?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Payload for contract deployment transactions
|
|
12
|
+
*/
|
|
13
|
+
export interface ContractDeployPayload {
|
|
14
|
+
source: string;
|
|
15
|
+
constructorArgs: any[];
|
|
16
|
+
metadata?: ContractMetadata;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Transaction content type for contract deployment operations
|
|
20
|
+
*/
|
|
21
|
+
export type ContractDeployTransactionContent = Omit<TransactionContent, 'type' | 'data'> & {
|
|
22
|
+
type: 'contractDeploy';
|
|
23
|
+
data: ['contractDeploy', ContractDeployPayload];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Complete contract deployment transaction interface
|
|
27
|
+
*/
|
|
28
|
+
export interface ContractDeployTransaction extends Omit<Transaction, 'content'> {
|
|
29
|
+
content: ContractDeployTransactionContent;
|
|
30
|
+
}
|
|
31
|
+
export default ContractDeployTransaction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractDeployTransaction.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/ContractDeployTransaction.ts"],"names":[],"mappings":""}
|
|
@@ -8,6 +8,8 @@ export * from './IdentityTransaction';
|
|
|
8
8
|
export * from './InstantMessagingTransaction';
|
|
9
9
|
export * from './NativeBridgeTransaction';
|
|
10
10
|
export * from './StorageTransaction';
|
|
11
|
+
export * from './ContractDeployTransaction';
|
|
12
|
+
export * from './ContractCallTransaction';
|
|
11
13
|
import { L2PSTransaction } from './L2PSTransaction';
|
|
12
14
|
import { L2PSHashTransaction } from './L2PSHashTransaction';
|
|
13
15
|
import { Web2Transaction } from './Web2Transaction';
|
|
@@ -18,4 +20,6 @@ import { IdentityTransaction } from './IdentityTransaction';
|
|
|
18
20
|
import { InstantMessagingTransaction } from './InstantMessagingTransaction';
|
|
19
21
|
import { NativeBridgeTransaction } from './NativeBridgeTransaction';
|
|
20
22
|
import { StorageTransaction } from './StorageTransaction';
|
|
21
|
-
|
|
23
|
+
import { ContractDeployTransaction } from './ContractDeployTransaction';
|
|
24
|
+
import { ContractCallTransaction } from './ContractCallTransaction';
|
|
25
|
+
export type SpecificTransaction = L2PSTransaction | L2PSHashTransaction | Web2Transaction | CrosschainTransaction | NativeTransaction | DemosworkTransaction | IdentityTransaction | InstantMessagingTransaction | NativeBridgeTransaction | StorageTransaction | ContractDeployTransaction | ContractCallTransaction;
|
|
@@ -24,4 +24,6 @@ __exportStar(require("./IdentityTransaction"), exports);
|
|
|
24
24
|
__exportStar(require("./InstantMessagingTransaction"), exports);
|
|
25
25
|
__exportStar(require("./NativeBridgeTransaction"), exports);
|
|
26
26
|
__exportStar(require("./StorageTransaction"), exports);
|
|
27
|
+
__exportStar(require("./ContractDeployTransaction"), exports);
|
|
28
|
+
__exportStar(require("./ContractCallTransaction"), exports);
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,wDAAqC;AACrC,oDAAiC;AACjC,0DAAuC;AACvC,sDAAmC;AACnC,yDAAsC;AACtC,wDAAqC;AACrC,gEAA6C;AAC7C,4DAAyC;AACzC,uDAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,wDAAqC;AACrC,oDAAiC;AACjC,0DAAuC;AACvC,sDAAmC;AACnC,yDAAsC;AACtC,wDAAqC;AACrC,gEAA6C;AAC7C,4DAAyC;AACzC,uDAAoC;AACpC,8DAA2C;AAC3C,4DAAyC"}
|
|
@@ -10,8 +10,9 @@ export interface IWeb2Result {
|
|
|
10
10
|
statusText: string;
|
|
11
11
|
headers: IncomingHttpHeaders;
|
|
12
12
|
data: any;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
responseHash: string;
|
|
14
|
+
responseHeadersHash: string;
|
|
15
|
+
requestHash?: string;
|
|
15
16
|
txHash?: string;
|
|
16
17
|
}
|
|
17
18
|
export interface IWeb2Request {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/web2/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/web2/index.ts"],"names":[],"mappings":";;;AAyCA,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,oCAAiB,CAAA;IACjB,6CAA0B,CAAA;AAC9B,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B"}
|
|
@@ -4,6 +4,7 @@ exports.web2Calls = exports.Web2Proxy = void 0;
|
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const skeletons_1 = require("./utils/skeletons");
|
|
6
6
|
const DemosTransactions_1 = require("./DemosTransactions");
|
|
7
|
+
const canonicalJson_1 = require("./utils/canonicalJson");
|
|
7
8
|
class Web2Proxy {
|
|
8
9
|
constructor(sessionId, demos) {
|
|
9
10
|
this._sessionId = sessionId;
|
|
@@ -23,22 +24,50 @@ class Web2Proxy {
|
|
|
23
24
|
*/
|
|
24
25
|
async startProxy({ url, method, options = {
|
|
25
26
|
headers: {},
|
|
26
|
-
payload:
|
|
27
|
+
payload: undefined,
|
|
27
28
|
authorization: "",
|
|
28
29
|
}, }) {
|
|
29
30
|
// Create a fresh copy of web2Request for each call
|
|
30
31
|
const freshWeb2Request = { ...skeletons_1.web2_request };
|
|
32
|
+
// Shallow-merge headers without mutating caller's object
|
|
33
|
+
const callerHeaders = options?.headers ? { ...options.headers } : {};
|
|
31
34
|
freshWeb2Request.raw = {
|
|
32
35
|
...freshWeb2Request.raw,
|
|
33
36
|
action: types_1.EnumWeb2Actions.START_PROXY,
|
|
34
37
|
method,
|
|
35
38
|
url,
|
|
36
|
-
headers:
|
|
39
|
+
headers: callerHeaders,
|
|
37
40
|
};
|
|
41
|
+
// Validate and canonicalize
|
|
42
|
+
let canonicalPayload = undefined;
|
|
43
|
+
if (options?.payload !== undefined) {
|
|
44
|
+
if (typeof options.payload === "object") {
|
|
45
|
+
(0, canonicalJson_1.validatePureJson)(options.payload);
|
|
46
|
+
canonicalPayload = (0, canonicalJson_1.canonicalJSONStringify)(options.payload);
|
|
47
|
+
// Only set JSON content-type if not already set by caller
|
|
48
|
+
if (!Object.keys(callerHeaders).some(h => h.toLowerCase() === "content-type")) {
|
|
49
|
+
callerHeaders["Content-Type"] = "application/json";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (typeof options.payload === "string") {
|
|
53
|
+
// Heuristic warning for accidental double-stringify
|
|
54
|
+
if ((0, canonicalJson_1.looksLikeJsonString)(options.payload)) {
|
|
55
|
+
console.warn("[Web2Calls] String payload looks like JSON. It will be used as raw bytes; if you intended object canonicalization, pass the object instead.");
|
|
56
|
+
}
|
|
57
|
+
canonicalPayload = options.payload;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// numbers/booleans/null are allowed by fetch/XHR as body. Use JSON.stringify semantics explicitly
|
|
61
|
+
canonicalPayload = JSON.stringify(options.payload);
|
|
62
|
+
if (!Object.keys(callerHeaders).some(h => h.toLowerCase() === "content-type")) {
|
|
63
|
+
callerHeaders["Content-Type"] = "application/json";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
38
67
|
const response = await this._demos.call("web2ProxyRequest", {
|
|
39
68
|
web2Request: freshWeb2Request,
|
|
40
69
|
sessionId: this._sessionId,
|
|
41
|
-
payload:
|
|
70
|
+
payload: canonicalPayload, // can be undefined ⇒ no body
|
|
42
71
|
authorization: options?.authorization,
|
|
43
72
|
});
|
|
44
73
|
const web2Payload = {
|
|
@@ -54,8 +83,11 @@ class Web2Proxy {
|
|
|
54
83
|
timestamp: Date.now(),
|
|
55
84
|
status: response.response.status,
|
|
56
85
|
headers: response.response.headers,
|
|
57
|
-
|
|
58
|
-
|
|
86
|
+
responseHash: response.response.responseHash,
|
|
87
|
+
responseHeadersHash: response.response.responseHeadersHash,
|
|
88
|
+
...(response.response.requestHash
|
|
89
|
+
? { requestHash: response.response.requestHash }
|
|
90
|
+
: {}),
|
|
59
91
|
statusText: response.response.statusText,
|
|
60
92
|
},
|
|
61
93
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Web2Calls.js","sourceRoot":"","sources":["../../../src/websdk/Web2Calls.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AACzC,iDAAgD;AAChD,2DAAuD;
|
|
1
|
+
{"version":3,"file":"Web2Calls.js","sourceRoot":"","sources":["../../../src/websdk/Web2Calls.ts"],"names":[],"mappings":";;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zC,MAAM,MAAM,GAAgB;YACxB,GAAG,QAAQ,CAAC,QAAQ;YACpB,MAAM;SACT,CAAA;QACD,OAAO,MAAM,CAAA;IACjB,CAAC;CACJ;AAlID,8BAkIC;AAED;;GAEG;AACU,QAAA,SAAS,GAAG;IACrB;;;;OAIG;IACH,UAAU,EAAE,KAAK,EAAE,KAAY,EAAsB,EAAE;QACnD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAA;QAEjC,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAClE,CAAC;QAED,kDAAkD;QAClD,MAAM,gBAAgB,GAAG,EAAE,GAAG,wBAAY,EAAE,CAAA;QAC5C,gBAAgB,CAAC,GAAG,GAAG;YACnB,GAAG,gBAAgB,CAAC,GAAG;YACvB,MAAM,EAAE,uBAAe,CAAC,MAAM;SACjC,CAAA;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAClD,WAAW,EAAE,gBAAgB;SAChC,CAAC,CAAA;QAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAA;QACpD,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACrD,CAAC;QAED,OAAO,IAAI,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;IAC1C,CAAC;CACJ,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.canonicalJSONStringify = canonicalJSONStringify;
|
|
4
|
+
exports.validatePureJson = validatePureJson;
|
|
5
|
+
exports.looksLikeJsonString = looksLikeJsonString;
|
|
6
|
+
function canonicalJSONStringify(value) {
|
|
7
|
+
strictValidate(value, new Set());
|
|
8
|
+
return stableStringify(value);
|
|
9
|
+
}
|
|
10
|
+
// Strict validation: reject undefined/function/symbol/BigInt anywhere
|
|
11
|
+
function strictValidate(value, seen) {
|
|
12
|
+
const t = typeof value;
|
|
13
|
+
if (t === "undefined" ||
|
|
14
|
+
t === "function" ||
|
|
15
|
+
t === "symbol" ||
|
|
16
|
+
t === "bigint") {
|
|
17
|
+
throw new Error(`Non-JSON value encountered: ${t}`);
|
|
18
|
+
}
|
|
19
|
+
if (value === null)
|
|
20
|
+
return;
|
|
21
|
+
if (t !== "object")
|
|
22
|
+
return;
|
|
23
|
+
if (seen.has(value))
|
|
24
|
+
throw new Error("Circular reference detected in JSON payload");
|
|
25
|
+
seen.add(value);
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
for (const v of value)
|
|
28
|
+
strictValidate(v, seen);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const proto = Object.getPrototypeOf(value);
|
|
32
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
33
|
+
throw new Error(`Only plain objects are supported. Found prototype: ${proto?.constructor?.name}`);
|
|
34
|
+
}
|
|
35
|
+
for (const v of Object.values(value)) {
|
|
36
|
+
strictValidate(v, seen);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function validatePureJson(value, seen = new Set()) {
|
|
40
|
+
// Backward-compatible validator: same strict rules as above
|
|
41
|
+
strictValidate(value, seen);
|
|
42
|
+
}
|
|
43
|
+
function looksLikeJsonString(str) {
|
|
44
|
+
const s = str.trim();
|
|
45
|
+
return ((s.startsWith("{") && s.endsWith("}")) ||
|
|
46
|
+
(s.startsWith("[") && s.endsWith("]")));
|
|
47
|
+
}
|
|
48
|
+
function stableStringify(value) {
|
|
49
|
+
const t = typeof value;
|
|
50
|
+
if (value === null || t === "number" || t === "boolean" || t === "string") {
|
|
51
|
+
return JSON.stringify(value);
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(value)) {
|
|
54
|
+
const items = value.map(v => stableStringify(v));
|
|
55
|
+
return `[${items.join(",")}]`;
|
|
56
|
+
}
|
|
57
|
+
// object (validated as plain)
|
|
58
|
+
const obj = value;
|
|
59
|
+
const keys = Object.keys(obj).sort();
|
|
60
|
+
const parts = [];
|
|
61
|
+
for (const key of keys) {
|
|
62
|
+
const k = JSON.stringify(key);
|
|
63
|
+
const v = stableStringify(obj[key]);
|
|
64
|
+
parts.push(`${k}:${v}`);
|
|
65
|
+
}
|
|
66
|
+
return `{${parts.join(",")}}`;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=canonicalJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalJson.js","sourceRoot":"","sources":["../../../../src/websdk/utils/canonicalJson.ts"],"names":[],"mappings":";;AAAA,wDAGC;AAqCD,4CAGC;AAED,kDAMC;AAnDD,SAAgB,sBAAsB,CAAC,KAAc;IACjD,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,CAAC,CAAA;IAChC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC;AAED,sEAAsE;AACtE,SAAS,cAAc,CAAC,KAAc,EAAE,IAAc;IAClD,MAAM,CAAC,GAAG,OAAO,KAAK,CAAA;IACtB,IACI,CAAC,KAAK,WAAW;QACjB,CAAC,KAAK,UAAU;QAChB,CAAC,KAAK,QAAQ;QACd,CAAC,KAAK,QAAQ,EAChB,CAAC;QACC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAA;IACvD,CAAC;IACD,IAAI,KAAK,KAAK,IAAI;QAAE,OAAM;IAC1B,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAM;IAE1B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAClE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAEf,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,KAAK,MA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KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,KAAK,GAAI,KAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/D,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;IACjC,CAAC;IACD,8BAA8B;IAC9B,MAAM,GAAG,GAAG,KAAgC,CAAA;IAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IACpC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QAC7B,MAAM,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QACnC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC3B,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kynesyslabs/demosdk",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.21",
|
|
4
4
|
"description": "Demosdk is a JavaScript/TypeScript SDK that provides a unified interface for interacting with Demos network",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"test:referrals": "rm -rf build && jest --testMatch '**/tests/**/referrals.spec*.ts' --testPathIgnorePatterns **/tests/**/chainProvider* **/tests/utils/* **/tests/**/template* --verbose",
|
|
47
47
|
"test:evm": "rm -rf build && jest --testMatch '**/tests/**/evm.spec*.ts' --testPathIgnorePatterns **/tests/**/chainProvider* **/tests/utils/* **/tests/**/template* --verbose",
|
|
48
48
|
"test:aptos": "node --require ts-node/register --require tsconfig-paths/register --test src/tests/multichain/aptos.node.spec.ts",
|
|
49
|
-
"test:aptos:only": "node --require ts-node/register --require tsconfig-paths/register --test --test-only src/tests/multichain/aptos.node.spec.ts"
|
|
49
|
+
"test:aptos:only": "node --require ts-node/register --require tsconfig-paths/register --test --test-only src/tests/multichain/aptos.node.spec.ts",
|
|
50
|
+
"test:canonical": "jest --testPathPattern=utils.test.ts --verbose"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
53
|
"@aptos-labs/ts-sdk": "^1.28.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SmartContractTransaction.js","sourceRoot":"","sources":["../../../../../src/types/blockchain/TransactionSubtypes/SmartContractTransaction.ts"],"names":[],"mappings":""}
|