@kynesyslabs/demosdk 1.0.0
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/README.md +59 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +30 -0
- package/build/index.js.map +1 -0
- package/build/multichain/core/evm.d.ts +56 -0
- package/build/multichain/core/evm.js +196 -0
- package/build/multichain/core/evm.js.map +1 -0
- package/build/multichain/core/ibc.d.ts +50 -0
- package/build/multichain/core/ibc.js +224 -0
- package/build/multichain/core/ibc.js.map +1 -0
- package/build/multichain/core/index.d.ts +7 -0
- package/build/multichain/core/index.js +19 -0
- package/build/multichain/core/index.js.map +1 -0
- package/build/multichain/core/multiversx.d.ts +38 -0
- package/build/multichain/core/multiversx.js +230 -0
- package/build/multichain/core/multiversx.js.map +1 -0
- package/build/multichain/core/types/defaultChain.d.ts +150 -0
- package/build/multichain/core/types/defaultChain.js +49 -0
- package/build/multichain/core/types/defaultChain.js.map +1 -0
- package/build/multichain/core/types/interfaces.d.ts +82 -0
- package/build/multichain/core/types/interfaces.js +3 -0
- package/build/multichain/core/types/interfaces.js.map +1 -0
- package/build/multichain/core/utils.d.ts +9 -0
- package/build/multichain/core/utils.js +22 -0
- package/build/multichain/core/utils.js.map +1 -0
- package/build/multichain/core/xrp.d.ts +54 -0
- package/build/multichain/core/xrp.js +189 -0
- package/build/multichain/core/xrp.js.map +1 -0
- package/build/multichain/index.d.ts +3 -0
- package/build/multichain/index.js +30 -0
- package/build/multichain/index.js.map +1 -0
- package/build/multichain/localsdk/evm.d.ts +25 -0
- package/build/multichain/localsdk/evm.js +61 -0
- package/build/multichain/localsdk/evm.js.map +1 -0
- package/build/multichain/localsdk/ibc.d.ts +10 -0
- package/build/multichain/localsdk/ibc.js +25 -0
- package/build/multichain/localsdk/ibc.js.map +1 -0
- package/build/multichain/localsdk/index.d.ts +3 -0
- package/build/multichain/localsdk/index.js +10 -0
- package/build/multichain/localsdk/index.js.map +1 -0
- package/build/multichain/localsdk/multiversx.d.ts +16 -0
- package/build/multichain/localsdk/multiversx.js +51 -0
- package/build/multichain/localsdk/multiversx.js.map +1 -0
- package/build/multichain/localsdk/xrp.d.ts +22 -0
- package/build/multichain/localsdk/xrp.js +77 -0
- package/build/multichain/localsdk/xrp.js.map +1 -0
- package/build/multichain/websdk/evm.d.ts +4 -0
- package/build/multichain/websdk/evm.js +11 -0
- package/build/multichain/websdk/evm.js.map +1 -0
- package/build/multichain/websdk/ibc.d.ts +4 -0
- package/build/multichain/websdk/ibc.js +12 -0
- package/build/multichain/websdk/ibc.js.map +1 -0
- package/build/multichain/websdk/index.d.ts +3 -0
- package/build/multichain/websdk/index.js +10 -0
- package/build/multichain/websdk/index.js.map +1 -0
- package/build/multichain/websdk/multiversx.d.ts +14 -0
- package/build/multichain/websdk/multiversx.js +57 -0
- package/build/multichain/websdk/multiversx.js.map +1 -0
- package/build/multichain/websdk/xrp.d.ts +4 -0
- package/build/multichain/websdk/xrp.js +11 -0
- package/build/multichain/websdk/xrp.js.map +1 -0
- package/build/types/ISignature.d.ts +5 -0
- package/build/types/ISignature.js +3 -0
- package/build/types/ISignature.js.map +1 -0
- package/build/types/Operation.d.ts +11 -0
- package/build/types/Operation.js +3 -0
- package/build/types/Operation.js.map +1 -0
- package/build/types/Transaction.d.ts +10 -0
- package/build/types/Transaction.js +3 -0
- package/build/types/Transaction.js.map +1 -0
- package/build/types/TransactionContent.d.ts +13 -0
- package/build/types/TransactionContent.js +3 -0
- package/build/types/TransactionContent.js.map +1 -0
- package/build/types/TxFee.d.ts +5 -0
- package/build/types/TxFee.js +3 -0
- package/build/types/TxFee.js.map +1 -0
- package/build/types/ValidityData.d.ts +14 -0
- package/build/types/ValidityData.js +3 -0
- package/build/types/ValidityData.js.map +1 -0
- package/build/types/index.d.ts +6 -0
- package/build/types/index.js +3 -0
- package/build/types/index.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IBC = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
// INFO: Websdk is the same as the core sdk
|
|
6
|
+
class IBC extends core_1.IBC {
|
|
7
|
+
constructor(rpc_url) {
|
|
8
|
+
super(rpc_url);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.IBC = IBC;
|
|
12
|
+
//# sourceMappingURL=ibc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ibc.js","sourceRoot":"","sources":["../../../../src/multichain/websdk/ibc.ts"],"names":[],"mappings":";;;AAAA,4CAAuE;AAEvE,2CAA2C;AAC3C,MAAa,GAAI,SAAQ,UAAU;IAC/B,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;CAGJ;AAND,kBAMC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IBC = exports.EVM = exports.XRPL = void 0;
|
|
4
|
+
var xrp_1 = require("./xrp");
|
|
5
|
+
Object.defineProperty(exports, "XRPL", { enumerable: true, get: function () { return xrp_1.XRPL; } });
|
|
6
|
+
var evm_1 = require("./evm");
|
|
7
|
+
Object.defineProperty(exports, "EVM", { enumerable: true, get: function () { return evm_1.EVM; } });
|
|
8
|
+
var ibc_1 = require("./ibc");
|
|
9
|
+
Object.defineProperty(exports, "IBC", { enumerable: true, get: function () { return ibc_1.IBC; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/multichain/websdk/index.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAAnB,2FAAA,IAAI,OAAA;AACb,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MULTIVERSX as EGLDCore, EGLDSignTxOptions, IDefaultChainWeb } from '../core';
|
|
2
|
+
import { IPlainTransactionObject, Transaction } from '@multiversx/sdk-core';
|
|
3
|
+
import { ExtensionProvider } from '@multiversx/sdk-extension-provider';
|
|
4
|
+
import { UserSigner } from '@multiversx/sdk-wallet';
|
|
5
|
+
export declare class MULTIVERSX extends EGLDCore implements IDefaultChainWeb {
|
|
6
|
+
constructor(rpc_url: string);
|
|
7
|
+
/**
|
|
8
|
+
* Connect a Multiversx wallet. Pass the `keyFile` JSON string as the `privateKey` and its `password` to override the De-Fi wallet prompt.
|
|
9
|
+
*/
|
|
10
|
+
connectWallet(privateKey?: string, options?: {
|
|
11
|
+
password: string;
|
|
12
|
+
}): Promise<ExtensionProvider | UserSigner>;
|
|
13
|
+
signTransactions(transactions: Transaction[], options?: EGLDSignTxOptions): Promise<IPlainTransactionObject[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MULTIVERSX = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
const sdk_extension_provider_1 = require("@multiversx/sdk-extension-provider");
|
|
6
|
+
class MULTIVERSX extends core_1.MULTIVERSX {
|
|
7
|
+
constructor(rpc_url) {
|
|
8
|
+
super(rpc_url);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Connect a Multiversx wallet. Pass the `keyFile` JSON string as the `privateKey` and its `password` to override the De-Fi wallet prompt.
|
|
12
|
+
*/
|
|
13
|
+
// @ts-expect-error // INFO: Return type error
|
|
14
|
+
async connectWallet(privateKey, options) {
|
|
15
|
+
if (privateKey && options?.password) {
|
|
16
|
+
await this.connectKeyFileWallet(privateKey, options.password);
|
|
17
|
+
return this.wallet;
|
|
18
|
+
}
|
|
19
|
+
this.wallet = sdk_extension_provider_1.ExtensionProvider.getInstance();
|
|
20
|
+
await this.wallet.init();
|
|
21
|
+
// INFO: wallet.isInitialized() checks if the wallet is installed.
|
|
22
|
+
// It's equivalent to checking for `window.elrondWallet` object which is injected by the extension
|
|
23
|
+
// LINK to src: https://github.com/multiversx/mx-sdk-js-extension-provider/blob/36518d0fe0b295de8d2b977727f0c30cdc014c78/src/extensionProvider.ts#L45
|
|
24
|
+
if (!this.wallet.isInitialized()) {
|
|
25
|
+
throw new Error('Wallet not detected. Is the MultiversX DeFi Wallet extension installed?');
|
|
26
|
+
}
|
|
27
|
+
await this.wallet.login();
|
|
28
|
+
return this.wallet;
|
|
29
|
+
}
|
|
30
|
+
async signTransactions(transactions, options) {
|
|
31
|
+
(0, core_1.required)(this.wallet || options?.privateKey, 'Wallet not connected');
|
|
32
|
+
// INFO: Override wallet connection
|
|
33
|
+
if (options?.privateKey) {
|
|
34
|
+
await this.connectWallet(options.privateKey, {
|
|
35
|
+
password: options.password,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
transactions = await this.addTxNonces(transactions);
|
|
39
|
+
try {
|
|
40
|
+
// INFO: When wallet is loaded from Extension
|
|
41
|
+
transactions = await this.wallet.signTransactions(transactions);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
for (const tx of transactions) {
|
|
45
|
+
const serializedTx = tx.serializeForSigning();
|
|
46
|
+
const txSign = await this.wallet.sign(serializedTx);
|
|
47
|
+
tx.applySignature(txSign);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return transactions.map((tx) => {
|
|
51
|
+
// INFO: Return plain objects
|
|
52
|
+
return tx.toSendable();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.MULTIVERSX = MULTIVERSX;
|
|
57
|
+
//# sourceMappingURL=multiversx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversx.js","sourceRoot":"","sources":["../../../../src/multichain/websdk/multivers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ACD,6CAA6C;YAC7C,YAAY,GAAG,MACX,IAAI,CAAC,MACR,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAA;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;gBAC5B,MAAM,YAAY,GAAG,EAAE,CAAC,mBAAmB,EAAE,CAAA;gBAC7C,MAAM,MAAM,GAAG,MAAO,IAAI,CAAC,MAAqB,CAAC,IAAI,CACjD,YAAY,CACf,CAAA;gBAED,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;YAC7B,CAAC;QACL,CAAC;QAED,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;YAC3B,6BAA6B;YAC7B,OAAO,EAAE,CAAC,UAAU,EAAE,CAAA;QAC1B,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AAzED,gCAyEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XRPL = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
class XRPL extends core_1.XRPL {
|
|
6
|
+
constructor(rpc_url) {
|
|
7
|
+
super(rpc_url);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.XRPL = XRPL;
|
|
11
|
+
//# sourceMappingURL=xrp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xrp.js","sourceRoot":"","sources":["../../../../src/multichain/websdk/xrp.ts"],"names":[],"mappings":";;;AAAA,4CAAyE;AAEzE,MAAa,IAAK,SAAQ,WAAW;IACjC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;CAGJ;AAND,oBAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISignature.js","sourceRoot":"","sources":["../../../src/types/ISignature.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Operation.js","sourceRoot":"","sources":["../../../src/types/Operation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ISignature } from "./ISignature";
|
|
2
|
+
import { TransactionContent } from "./TransactionContent";
|
|
3
|
+
import * as forge from "node-forge";
|
|
4
|
+
export interface Transaction {
|
|
5
|
+
content: TransactionContent;
|
|
6
|
+
signature: ISignature | forge.pki.ed25519.BinaryBuffer;
|
|
7
|
+
hash: string;
|
|
8
|
+
status: string;
|
|
9
|
+
blockNumber: number;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../src/types/Transaction.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import forge from 'node-forge';
|
|
2
|
+
import { TxFee } from './TxFee';
|
|
3
|
+
import { ISignature } from './ISignature';
|
|
4
|
+
export interface TransactionContent {
|
|
5
|
+
type: string;
|
|
6
|
+
from: forge.pki.ed25519.BinaryBuffer | forge.pki.PublicKey | ISignature;
|
|
7
|
+
to: forge.pki.ed25519.BinaryBuffer | forge.pki.PrivateKey | ISignature;
|
|
8
|
+
amount: number;
|
|
9
|
+
data: [string, string];
|
|
10
|
+
nonce: number;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
transaction_fee: TxFee;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionContent.js","sourceRoot":"","sources":["../../../src/types/TransactionContent.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TxFee.js","sourceRoot":"","sources":["../../../src/types/TxFee.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Operation } from './Operation';
|
|
2
|
+
import { pki } from 'node-forge';
|
|
3
|
+
import { Transaction } from './Transaction';
|
|
4
|
+
export interface ValidityData {
|
|
5
|
+
data: {
|
|
6
|
+
valid: boolean;
|
|
7
|
+
reference_block: number;
|
|
8
|
+
message: string;
|
|
9
|
+
gas_operation: Operation;
|
|
10
|
+
transaction: Transaction;
|
|
11
|
+
};
|
|
12
|
+
signature: pki.ed25519.BinaryBuffer;
|
|
13
|
+
rpc_public_key: pki.ed25519.BinaryBuffer;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidityData.js","sourceRoot":"","sources":["../../../src/types/ValidityData.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ISignature } from './ISignature';
|
|
2
|
+
export { Operation } from './Operation';
|
|
3
|
+
export { Transaction } from './Transaction';
|
|
4
|
+
export { TransactionContent } from './TransactionContent';
|
|
5
|
+
export { TxFee } from './TxFee';
|
|
6
|
+
export { ValidityData } from './ValidityData';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kynesyslabs/demosdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "build/index.js",
|
|
5
|
+
"types": "build/index.d.ts",
|
|
6
|
+
"author": "Kynesys Labs",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"files": [
|
|
9
|
+
"build/",
|
|
10
|
+
"!build/tests"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./build/index.js",
|
|
14
|
+
"./types": "./build/types/index.js",
|
|
15
|
+
"./xm/*": "./build/multichain/*"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rm -rf build && tsc && resolve-tspaths && mv build/src/* build/ && rm -rf build/src",
|
|
19
|
+
"publish": "yarn npm publish",
|
|
20
|
+
"test:multichain": "rm -rf build && jest --testMatch '**/tests/**/*.ts' --testPathIgnorePatterns **/tests/**/chainProvider* **/tests/utils/* **/tests/**/template* --verbose"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@cosmjs/proto-signing": "^0.32.3",
|
|
24
|
+
"@cosmjs/stargate": "^0.32.3",
|
|
25
|
+
"@multiversx/sdk-core": "^13.0.0",
|
|
26
|
+
"@multiversx/sdk-extension-provider": "^3.0.0",
|
|
27
|
+
"@multiversx/sdk-network-providers": "^2.4.3",
|
|
28
|
+
"@multiversx/sdk-wallet": "^4.4.0",
|
|
29
|
+
"ethers": "^6.11.1",
|
|
30
|
+
"node-forge": "^1.3.1",
|
|
31
|
+
"xrpl": "^3.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/jest": "^29.5.12",
|
|
35
|
+
"@types/node": "^20.12.4",
|
|
36
|
+
"@types/node-forge": "^1.3.11",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"resolve-tspaths": "^0.8.18",
|
|
39
|
+
"ts-jest": "^29.1.2",
|
|
40
|
+
"ts-node": "^10.9.2",
|
|
41
|
+
"typescript": "^5.4.3"
|
|
42
|
+
},
|
|
43
|
+
"packageManager": "yarn@3.8.0"
|
|
44
|
+
}
|