@kynesyslabs/demosdk 2.2.36 → 2.2.39

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.
@@ -4,5 +4,5 @@ import RubicBridge from "./rubicBridge";
4
4
  export { BLOCKCHAIN_NAME, CROSS_CHAIN_TRADE_TYPE, CrossChainTrade, RubicSdkError, WrappedCrossChainTrade, } from "rubic-sdk";
5
5
  import { methods as NativeBridgeMethods } from "./nativeBridge";
6
6
  export { NativeBridgeMethods };
7
- export { BridgeOperation as NativeBridgeOperation, NativeBridgePayload, SupportedChain as NativeBridgeSupportedChain, SupportedStablecoin as NativeBridgeSupportedStablecoin, SupportedEVMChain as NativeBridgeSupportedEVMChain, supportedChains as NativeBridgeSupportedChains, supportedStablecoins as NativeBridgeSupportedStablecoins, supportedEVMChains as NativeBridgeSupportedEVMChains, usdcContracts as NativeBridgeUSDCContracts, usdcAbi as NativeBridgeUSDCAbi, } from "./nativeBridgeTypes";
7
+ export { BridgeOperation as NativeBridgeOperation, BridgeOperationCompiled as NativeBridgeOperationCompiled, SupportedChain as NativeBridgeSupportedChain, SupportedStablecoin as NativeBridgeSupportedStablecoin, SupportedEVMChain as NativeBridgeSupportedEVMChain, supportedChains as NativeBridgeSupportedChains, supportedStablecoins as NativeBridgeSupportedStablecoins, supportedEVMChains as NativeBridgeSupportedEVMChains, usdcContracts as NativeBridgeUSDCContracts, usdcAbi as NativeBridgeUSDCAbi, } from "./nativeBridgeTypes";
8
8
  export { RubicBridge };
@@ -1,12 +1,19 @@
1
- import { BridgeOperation } from "./nativeBridgeTypes";
1
+ import { BridgeOperationCompiled } from "./nativeBridgeTypes";
2
2
  import { Transaction } from "../types/blockchain/Transaction";
3
+ import { RPCRequest } from "../types";
3
4
  export declare const methods: {
4
5
  /**
5
- * Generates a new operation, its corresponding Transaction and returns it
6
+ * Generates a new operation, ready to be sent to the node as a RPCRequest
6
7
  * TODO Implement the params
8
+ * REVIEW Should we use the identity somehow or we keep using the private key?
7
9
  */
8
- generateOperation(): {
9
- operation: BridgeOperation;
10
- transaction: Transaction;
11
- };
10
+ generateOperation(privateKey: string): RPCRequest;
11
+ /**
12
+ *
13
+ * @param compiled operation
14
+ * @param signature
15
+ * @param rpc
16
+ * @returns
17
+ */
18
+ generateOperationTx(compiled: BridgeOperationCompiled): Transaction;
12
19
  };
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.methods = void 0;
4
- const websdk_1 = require("../websdk");
4
+ const encryption_1 = require("../encryption");
5
5
  exports.methods = {
6
6
  /**
7
- * Generates a new operation, its corresponding Transaction and returns it
7
+ * Generates a new operation, ready to be sent to the node as a RPCRequest
8
8
  * TODO Implement the params
9
+ * REVIEW Should we use the identity somehow or we keep using the private key?
9
10
  */
10
- generateOperation() {
11
+ generateOperation(privateKey) {
11
12
  // Defining the operation
12
13
  const operation = {
13
14
  demoAddress: "",
@@ -20,11 +21,26 @@ exports.methods = {
20
21
  txHash: "",
21
22
  status: "empty",
22
23
  };
23
- // Defining the transaction
24
- var transaction = websdk_1.demos.transactions.empty();
25
- // TODO Implement the operation
26
- // TODO Implement the transaction
27
- return { operation, transaction };
24
+ // TODO Generate the operation based on parameters
25
+ // REVIEW Sign the operation
26
+ let opHash = encryption_1.Hashing.sha256(JSON.stringify(operation));
27
+ let signature = encryption_1.Cryptography.sign(opHash, privateKey);
28
+ let nodeCallPayload = {
29
+ method: "nativeBridge",
30
+ params: [operation]
31
+ };
32
+ return nodeCallPayload;
33
+ },
34
+ /**
35
+ *
36
+ * @param compiled operation
37
+ * @param signature
38
+ * @param rpc
39
+ * @returns
40
+ */
41
+ generateOperationTx(compiled) {
42
+ // TODO Implement the transaction once we have the compiled operation
43
+ return null;
28
44
  }
29
45
  };
30
46
  //# sourceMappingURL=nativeBridge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nativeBridge.js","sourceRoot":"","sources":["../../../src/bridge/nativeBridge.ts"],"names":[],"mappings":";;;AAEA,qCAAgC;AAEnB,QAAA,OAAO,GAAG;IAEnB;;;MAGE;IACF,iBAAiB;QACb,yBAAyB;QACzB,MAAM,SAAS,GAAoB;YAC/B,WAAW,EAAE,EAAE;YACf,WAAW,EAAE,IAAI;YACjB,gBAAgB,EAAE,IAAI;YACtB,aAAa,EAAE,EAAE;YACjB,kBAAkB,EAAE,EAAE;YACtB,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,OAAO;SAClB,CAAA;QAED,2BAA2B;QAC3B,IAAI,WAAW,GAAgB,cAAK,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QAEzD,gCAAgC;QAChC,iCAAiC;QAEjC,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,CAAA;IACnC,CAAC;CACJ,CAAA"}
1
+ {"version":3,"file":"nativeBridge.js","sourceRoot":"","sources":["../../../src/bridge/nativeBridge.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;AAOvC,QAAA,OAAO,GAAG;IAEnB;;;;MAIE;IACF,iBAAiB,CAAC,UAAkB;QAChC,yBAAyB;QACzB,MAAM,SAAS,GAAoB;YAC/B,WAAW,EAAE,EAAE;YACf,WAAW,EAAE,IAAI;YACjB,gBAAgB,EAAE,IAAI;YACtB,aAAa,EAAE,EAAE;YACjB,kBAAkB,EAAE,EAAE;YACtB,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,OAAO;SAClB,CAAA;QACD,kDAAkD;QAClD,4BAA4B;QAC5B,IAAI,MAAM,GAAG,oBAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAA;QACtD,IAAI,SAAS,GAAG,yBAAY,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;QACrD,IAAI,eAAe,GAAe;YAC9B,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,CAAC,SAAS,CAAC;SACtB,CAAA;QACD,OAAO,eAAe,CAAA;IAC1B,CAAC;IAED;;;;;;OAMG;IACH,mBAAmB,CAAC,QAAiC;QACjD,qEAAqE;QACrE,OAAO,IAAI,CAAA;IACf,CAAC;CACJ,CAAA"}
@@ -11,8 +11,21 @@ export type BridgeOperation = {
11
11
  txHash: string;
12
12
  status: "empty" | "pending" | "completed" | "failed";
13
13
  };
14
- export type NativeBridgePayload = {
15
- operation: BridgeOperation;
14
+ export type BridgeOperationCompiled = {
15
+ content: {
16
+ operation: BridgeOperation;
17
+ amountExpected: number;
18
+ validUntil: number;
19
+ } & ({
20
+ originChain: "EVM";
21
+ contractAddress: string;
22
+ contractABI: string[];
23
+ } | {
24
+ originChain: "SOLANA";
25
+ solanaAddress: string;
26
+ });
27
+ signature: string;
28
+ rpc: string;
16
29
  };
17
30
  export declare const supportedEVMChains: readonly ["eth", "polygon", "bsc", "arbitrum", "optimism", "avalanche", "base"];
18
31
  export declare const usdcContracts: {
@@ -26,6 +39,6 @@ export declare const usdcContracts: {
26
39
  SOLANA: string;
27
40
  };
28
41
  export declare const usdcAbi: string[];
29
- export type SupportedChain = typeof supportedChains[number];
30
- export type SupportedStablecoin = typeof supportedStablecoins[number];
31
- export type SupportedEVMChain = typeof supportedEVMChains[number];
42
+ export type SupportedChain = (typeof supportedChains)[number];
43
+ export type SupportedStablecoin = (typeof supportedStablecoins)[number];
44
+ export type SupportedEVMChain = (typeof supportedEVMChains)[number];
@@ -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;AAoBrD,2BAA2B;AACd,QAAA,kBAAkB,GAAG;IAC9B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E,MAAM,EAAE,8CAA8C,EAAE,qBAAqB;CAChF,CAAA;AAED,gCAAgC;AACnB,QAAA,OAAO,GAAG;IACnB,0DAA0D;IAC1D,0CAA0C;CAC7C,CAAA"}
@@ -9,8 +9,8 @@ import { INativePayload } from "../native";
9
9
  import { SubnetPayload } from "../../l2ps";
10
10
  import { IdentityPayload } from "../abstraction";
11
11
  import { InstantMessagingPayload } from "../instantMessaging";
12
- import { NativeBridgePayload } from "../../bridge/nativeBridgeTypes";
13
- export type TransactionContentData = ["web2Request", IWeb2Payload] | ["crosschainOperation", XMScript] | ["native", INativePayload] | ["demoswork", DemoScript] | ["subnet", SubnetPayload] | ["identity", IdentityPayload] | ["instantMessaging", InstantMessagingPayload] | ["nativeBridge", NativeBridgePayload];
12
+ import { BridgeOperationCompiled } from "../../bridge/nativeBridgeTypes";
13
+ export type TransactionContentData = ["web2Request", IWeb2Payload] | ["crosschainOperation", XMScript] | ["native", INativePayload] | ["demoswork", DemoScript] | ["subnet", SubnetPayload] | ["identity", IdentityPayload] | ["instantMessaging", InstantMessagingPayload] | ["nativeBridge", BridgeOperationCompiled];
14
14
  export interface TransactionContent {
15
15
  type: "web2Request" | "crosschainOperation" | "subnet" | "native" | "demoswork" | "genesis" | "NODE_ONLINE" | "identity" | "instantMessaging" | "nativeBridge";
16
16
  from: forge.pki.ed25519.BinaryBuffer | forge.pki.PublicKey | ISignature;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kynesyslabs/demosdk",
3
- "version": "2.2.36",
3
+ "version": "2.2.39",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "author": "Kynesys Labs",