@kynesyslabs/demosdk 2.2.39 → 2.2.40
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/bridge/nativeBridge.d.ts +10 -3
- package/build/bridge/nativeBridge.js +37 -12
- package/build/bridge/nativeBridge.js.map +1 -1
- package/build/bridge/nativeBridgeTypes.d.ts +6 -2
- package/build/bridge/nativeBridgeTypes.js +2 -1
- package/build/bridge/nativeBridgeTypes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { BridgeOperationCompiled } from "./nativeBridgeTypes";
|
|
1
|
+
import { BridgeOperationCompiled, SupportedChain, SupportedEVMChain, SupportedStablecoin, SupportedNonEVMChain } from "./nativeBridgeTypes";
|
|
2
2
|
import { Transaction } from "../types/blockchain/Transaction";
|
|
3
3
|
import { RPCRequest } from "../types";
|
|
4
4
|
export declare const methods: {
|
|
5
|
+
/**
|
|
6
|
+
* Validates the chain
|
|
7
|
+
* @param chain
|
|
8
|
+
* @param chainType
|
|
9
|
+
* @param isOrigin (useful for error messages)
|
|
10
|
+
*/
|
|
11
|
+
validateChain(chain: string, chainType: string, isOrigin: boolean): void;
|
|
5
12
|
/**
|
|
6
13
|
* Generates a new operation, ready to be sent to the node as a RPCRequest
|
|
7
14
|
* TODO Implement the params
|
|
8
15
|
* REVIEW Should we use the identity somehow or we keep using the private key?
|
|
9
|
-
|
|
10
|
-
generateOperation(privateKey: string): RPCRequest;
|
|
16
|
+
*/
|
|
17
|
+
generateOperation(privateKey: string, publicKey: string, originChainType: SupportedChain, originChain: SupportedEVMChain | SupportedNonEVMChain, destinationChainType: SupportedChain, destinationChain: SupportedEVMChain | SupportedNonEVMChain, originAddress: string, destinationAddress: string, amount: string, token: SupportedStablecoin): RPCRequest;
|
|
11
18
|
/**
|
|
12
19
|
*
|
|
13
20
|
* @param compiled operation
|
|
@@ -2,32 +2,57 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.methods = void 0;
|
|
4
4
|
const encryption_1 = require("../encryption");
|
|
5
|
+
const nativeBridgeTypes_1 = require("./nativeBridgeTypes");
|
|
5
6
|
exports.methods = {
|
|
7
|
+
/**
|
|
8
|
+
* Validates the chain
|
|
9
|
+
* @param chain
|
|
10
|
+
* @param chainType
|
|
11
|
+
* @param isOrigin (useful for error messages)
|
|
12
|
+
*/
|
|
13
|
+
validateChain(chain, chainType, isOrigin) {
|
|
14
|
+
const chainTypeStr = isOrigin ? "origin" : "destination";
|
|
15
|
+
if (chainType === "EVM") {
|
|
16
|
+
if (!nativeBridgeTypes_1.supportedEVMChains.includes(chain)) {
|
|
17
|
+
throw new Error(`Invalid ${chainTypeStr} chain: ${chain} is not a supported EVM`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
if (!nativeBridgeTypes_1.supportedNonEVMChains.includes(chain)) {
|
|
22
|
+
throw new Error(`Invalid ${chainTypeStr} chain: ${chain} is not a supported chain`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
6
26
|
/**
|
|
7
27
|
* Generates a new operation, ready to be sent to the node as a RPCRequest
|
|
8
28
|
* TODO Implement the params
|
|
9
29
|
* REVIEW Should we use the identity somehow or we keep using the private key?
|
|
10
|
-
|
|
11
|
-
generateOperation(privateKey) {
|
|
30
|
+
*/
|
|
31
|
+
generateOperation(privateKey, publicKey, originChainType, originChain, destinationChainType, destinationChain, originAddress, destinationAddress, amount, token) {
|
|
32
|
+
// Ensuring the chains are valid: throw an error if not
|
|
33
|
+
this.validateChain(originChain, originChainType, true);
|
|
34
|
+
this.validateChain(destinationChain, destinationChainType, false);
|
|
12
35
|
// Defining the operation
|
|
13
36
|
const operation = {
|
|
14
|
-
demoAddress:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
37
|
+
demoAddress: publicKey,
|
|
38
|
+
originChainType: originChainType,
|
|
39
|
+
originChain: originChain,
|
|
40
|
+
destinationChainType: destinationChainType,
|
|
41
|
+
destinationChain: destinationChain,
|
|
42
|
+
originAddress: originAddress,
|
|
43
|
+
destinationAddress: destinationAddress,
|
|
44
|
+
amount: amount,
|
|
45
|
+
token: token,
|
|
21
46
|
txHash: "",
|
|
22
47
|
status: "empty",
|
|
23
48
|
};
|
|
24
|
-
// TODO Generate the operation based on parameters
|
|
25
49
|
// REVIEW Sign the operation
|
|
26
50
|
let opHash = encryption_1.Hashing.sha256(JSON.stringify(operation));
|
|
27
51
|
let signature = encryption_1.Cryptography.sign(opHash, privateKey);
|
|
52
|
+
let hexSignature = new TextDecoder().decode(signature);
|
|
28
53
|
let nodeCallPayload = {
|
|
29
54
|
method: "nativeBridge",
|
|
30
|
-
params: [operation]
|
|
55
|
+
params: [operation, hexSignature],
|
|
31
56
|
};
|
|
32
57
|
return nodeCallPayload;
|
|
33
58
|
},
|
|
@@ -41,6 +66,6 @@ exports.methods = {
|
|
|
41
66
|
generateOperationTx(compiled) {
|
|
42
67
|
// TODO Implement the transaction once we have the compiled operation
|
|
43
68
|
return null;
|
|
44
|
-
}
|
|
69
|
+
},
|
|
45
70
|
};
|
|
46
71
|
//# sourceMappingURL=nativeBridge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeBridge.js","sourceRoot":"","sources":["../../../src/bridge/nativeBridge.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;
|
|
1
|
+
{"version":3,"file":"nativeBridge.js","sourceRoot":"","sources":["../../../src/bridge/nativeBridge.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;AACpD,2DAS4B;AAIf,QAAA,OAAO,GAAG;IACnB;;;;;OAKG;IACH,aAAa,CACT,KAAa,EACb,SAAiB,EACjB,QAAiB;QAEjB,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAA;QACxD,IAAI,S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AAA;QACrD,IAAI,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,eAAe,GAAe;YAC9B,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC;SACpC,CAAA;QACD,OAAO,eAAe,CAAA;IAC1B,CAAC;IAED;;;;;;OAMG;IACH,mBAAmB,CAAC,QAAiC;QACjD,qEAAqE;QACrE,OAAO,IAAI,CAAA;IACf,CAAC;CACJ,CAAA"}
|
|
@@ -2,8 +2,10 @@ export declare const supportedChains: readonly ["EVM", "SOLANA"];
|
|
|
2
2
|
export declare const supportedStablecoins: readonly ["USDC"];
|
|
3
3
|
export type BridgeOperation = {
|
|
4
4
|
demoAddress: string;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
originChainType: SupportedChain;
|
|
6
|
+
originChain: SupportedEVMChain | SupportedNonEVMChain;
|
|
7
|
+
destinationChainType: SupportedChain;
|
|
8
|
+
destinationChain: SupportedEVMChain | SupportedNonEVMChain;
|
|
7
9
|
originAddress: string;
|
|
8
10
|
destinationAddress: string;
|
|
9
11
|
amount: string;
|
|
@@ -28,6 +30,7 @@ export type BridgeOperationCompiled = {
|
|
|
28
30
|
rpc: string;
|
|
29
31
|
};
|
|
30
32
|
export declare const supportedEVMChains: readonly ["eth", "polygon", "bsc", "arbitrum", "optimism", "avalanche", "base"];
|
|
33
|
+
export declare const supportedNonEVMChains: readonly ["SOLANA"];
|
|
31
34
|
export declare const usdcContracts: {
|
|
32
35
|
ETHEREUM: string;
|
|
33
36
|
POLYGON: string;
|
|
@@ -42,3 +45,4 @@ export declare const usdcAbi: string[];
|
|
|
42
45
|
export type SupportedChain = (typeof supportedChains)[number];
|
|
43
46
|
export type SupportedStablecoin = (typeof supportedStablecoins)[number];
|
|
44
47
|
export type SupportedEVMChain = (typeof supportedEVMChains)[number];
|
|
48
|
+
export type SupportedNonEVMChain = (typeof supportedNonEVMChains)[number];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// We separate the types from the methods to avoid circular dependencies (transactions mainly)
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.usdcAbi = exports.usdcContracts = exports.supportedEVMChains = exports.supportedStablecoins = exports.supportedChains = void 0;
|
|
4
|
+
exports.usdcAbi = exports.usdcContracts = exports.supportedNonEVMChains = exports.supportedEVMChains = exports.supportedStablecoins = exports.supportedChains = void 0;
|
|
5
5
|
// Supported chains and stablecoins
|
|
6
6
|
exports.supportedChains = ["EVM", "SOLANA"];
|
|
7
7
|
exports.supportedStablecoins = ["USDC"];
|
|
@@ -15,6 +15,7 @@ exports.supportedEVMChains = [
|
|
|
15
15
|
"avalanche",
|
|
16
16
|
"base",
|
|
17
17
|
];
|
|
18
|
+
exports.supportedNonEVMChains = ["SOLANA"];
|
|
18
19
|
// USDC contract addresses for different chains (testnet addresses)
|
|
19
20
|
exports.usdcContracts = {
|
|
20
21
|
ETHEREUM: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", // Sepolia USDC
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeBridgeTypes.js","sourceRoot":"","sources":["../../../src/bridge/nativeBridgeTypes.ts"],"names":[],"mappings":";AAAA,8FAA8F;;;AAE9F,mCAAmC;AACtB,QAAA,eAAe,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAU,CAAA;AAC5C,QAAA,oBAAoB,GAAG,CAAC,MAAM,CAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"nativeBridgeTypes.js","sourceRoot":"","sources":["../../../src/bridge/nativeBridgeTypes.ts"],"names":[],"mappings":";AAAA,8FAA8F;;;AAE9F,mCAAmC;AACtB,QAAA,eAAe,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAU,CAAA;AAC5C,QAAA,oBAAoB,GAAG,CAAC,MAAM,CAAU,CAAA;AAwCrD,2BAA2B;AACd,QAAA,kBAAkB,GAAG;IAC9B,KAAK;IACL,SAAS;IACT,KAAK;IACL,UAAU;IACV,UAAU;IACV,WAAW;IACX,MAAM;CACA,CAAA;AAEG,QAAA,qBAAqB,GAAG,CAAC,QAAQ,CAAU,CAAA;AAExD,mEAAmE;AACtD,QAAA,aAAa,GAAG;IACzB,QAAQ,EAAE,4CAA4C,EAAE,eAAe;IACvE,OAAO,EAAE,4CAA4C,EAAE,cAAc;IACrE,GAAG,EAAE,4CAA4C,EAAE,mBAAmB;IACtE,QAAQ,EAAE,4CAA4C,EAAE,wBAAwB;IAChF,QAAQ,EAAE,4CAA4C,EAAE,wBAAwB;IAChF,SAAS,EAAE,4CAA4C,EAAE,YAAY;IACrE,IAAI,EAAE,4CAA4C,EAAE,oBAAoB;IACxE,MAAM,EAAE,8CAA8C,EAAE,qBAAqB;CAChF,CAAA;AAED,gCAAgC;AACnB,QAAA,OAAO,GAAG;IACnB,0DAA0D;IAC1D,0CAA0C;CAC7C,CAAA"}
|