@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,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.xrplGetLastSequence = exports.XRPL = exports.MULTIVERSX = exports.IBC = exports.EVM = exports.required = exports.DefaultChain = void 0;
|
|
4
|
+
var defaultChain_1 = require("./types/defaultChain");
|
|
5
|
+
Object.defineProperty(exports, "DefaultChain", { enumerable: true, get: function () { return defaultChain_1.DefaultChain; } });
|
|
6
|
+
var utils_1 = require("./utils");
|
|
7
|
+
Object.defineProperty(exports, "required", { enumerable: true, get: function () { return utils_1.required; } });
|
|
8
|
+
// SECTION: Chain SDKs
|
|
9
|
+
var evm_1 = require("./evm");
|
|
10
|
+
Object.defineProperty(exports, "EVM", { enumerable: true, get: function () { return evm_1.EVM; } });
|
|
11
|
+
var ibc_1 = require("./ibc");
|
|
12
|
+
Object.defineProperty(exports, "IBC", { enumerable: true, get: function () { return ibc_1.IBC; } });
|
|
13
|
+
var multiversx_1 = require("./multiversx");
|
|
14
|
+
Object.defineProperty(exports, "MULTIVERSX", { enumerable: true, get: function () { return multiversx_1.MULTIVERSX; } });
|
|
15
|
+
// The official XRPL Library is called "xrpl" which conflicts with the name of our XRPL SDK
|
|
16
|
+
var xrp_1 = require("./xrp");
|
|
17
|
+
Object.defineProperty(exports, "XRPL", { enumerable: true, get: function () { return xrp_1.XRPL; } });
|
|
18
|
+
Object.defineProperty(exports, "xrplGetLastSequence", { enumerable: true, get: function () { return xrp_1.xrplGetLastSequence; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/multichain/core/index.ts"],"names":[],"mappings":";;;AAAA,qDAM6B;AALzB,4GAAA,YAAY,OAAA;AAkBhB,iCAAkC;AAAzB,iGAAA,QAAQ,OAAA;AAEjB,sBAAsB;AACtB,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AAEnB,2FAA2F;AAC3F,6BAAiD;AAAxC,2FAAA,IAAI,OAAA;AAAE,0GAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IPlainTransactionObject, Transaction } from '@multiversx/sdk-core';
|
|
2
|
+
import { ExtensionProvider } from '@multiversx/sdk-extension-provider';
|
|
3
|
+
import { INetworkProvider } from '@multiversx/sdk-network-providers/out/interface';
|
|
4
|
+
import { UserSigner } from '@multiversx/sdk-wallet';
|
|
5
|
+
import { DefaultChain, EGLDSignTxOptions, IPayOptions } from './';
|
|
6
|
+
export declare class MULTIVERSX extends DefaultChain {
|
|
7
|
+
provider: INetworkProvider;
|
|
8
|
+
wallet: UserSigner | ExtensionProvider;
|
|
9
|
+
chainId: string;
|
|
10
|
+
constructor(rpc_url: string);
|
|
11
|
+
setRPC(rpc_url: string): void;
|
|
12
|
+
connect(): Promise<boolean>;
|
|
13
|
+
connectKeyFileWallet(keyFile: string, password: string): Promise<UserSigner>;
|
|
14
|
+
connectWallet(privateKey: string, options: {
|
|
15
|
+
password: string;
|
|
16
|
+
}): Promise<UserSigner>;
|
|
17
|
+
getAddress(): string;
|
|
18
|
+
getBalance(address: string): Promise<string>;
|
|
19
|
+
getTokenBalance(token_id: string): Promise<number>;
|
|
20
|
+
getNFTs(): Promise<import("@multiversx/sdk-network-providers").NonFungibleTokenOfAccountOnNetwork[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Signs a single transaction. Calls `signTransactions` with a single transaction and returns the first element of the result.
|
|
23
|
+
* @returns The signed transaction as a plain object
|
|
24
|
+
*/
|
|
25
|
+
signTransaction(transaction: Transaction, options: EGLDSignTxOptions): Promise<IPlainTransactionObject>;
|
|
26
|
+
protected addTxNonces(transactions: Transaction[]): Promise<Transaction[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Signs multiple transactions
|
|
29
|
+
* @returns The signed transactions as an array of plain objects
|
|
30
|
+
*/
|
|
31
|
+
signTransactions(transactions: Transaction[], options?: EGLDSignTxOptions): Promise<IPlainTransactionObject[]>;
|
|
32
|
+
preparePay(address: string, amount: string): Promise<IPlainTransactionObject>;
|
|
33
|
+
preparePays(payments: IPayOptions[]): Promise<IPlainTransactionObject[]>;
|
|
34
|
+
prepareTransfer(receiver: string, amount: string): Promise<IPlainTransactionObject>;
|
|
35
|
+
prepareTransfers(tranfers: IPayOptions[]): Promise<IPlainTransactionObject[]>;
|
|
36
|
+
disconnect(): Promise<boolean>;
|
|
37
|
+
getEmptyTransaction(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MULTIVERSX = void 0;
|
|
4
|
+
const sdk_core_1 = require("@multiversx/sdk-core");
|
|
5
|
+
const sdk_extension_provider_1 = require("@multiversx/sdk-extension-provider");
|
|
6
|
+
const sdk_network_providers_1 = require("@multiversx/sdk-network-providers");
|
|
7
|
+
const sdk_wallet_1 = require("@multiversx/sdk-wallet");
|
|
8
|
+
const core_1 = require("./");
|
|
9
|
+
class MULTIVERSX extends core_1.DefaultChain {
|
|
10
|
+
constructor(rpc_url) {
|
|
11
|
+
super(rpc_url);
|
|
12
|
+
this.chainId = '';
|
|
13
|
+
this.name = 'egld';
|
|
14
|
+
if (rpc_url) {
|
|
15
|
+
this.setRPC(rpc_url);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
setRPC(rpc_url) {
|
|
19
|
+
this.rpc_url = rpc_url;
|
|
20
|
+
this.provider = new sdk_network_providers_1.ApiNetworkProvider(this.rpc_url);
|
|
21
|
+
}
|
|
22
|
+
async connect() {
|
|
23
|
+
(0, core_1.required)(this.provider, 'Provider not connected');
|
|
24
|
+
try {
|
|
25
|
+
const networkConfig = await this.provider.getNetworkConfig();
|
|
26
|
+
this.chainId = networkConfig.ChainID;
|
|
27
|
+
this.connected = Boolean(this.chainId);
|
|
28
|
+
return this.connected;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
this.connected = false;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
// REVIEW: Where is this needed?
|
|
36
|
+
// Answer to that: src/routes/crosschain/xM_WalletConnectionCard.svelte
|
|
37
|
+
// static async create(rpc_url: any) {
|
|
38
|
+
// const instance = new MULTIVERSX(rpc_url)
|
|
39
|
+
// if (rpc_url) {
|
|
40
|
+
// await instance.connect()
|
|
41
|
+
// }
|
|
42
|
+
// return instance
|
|
43
|
+
// }
|
|
44
|
+
async connectKeyFileWallet(keyFile, password) {
|
|
45
|
+
try {
|
|
46
|
+
// INFO: Parse the keyFile JSON string
|
|
47
|
+
keyFile = JSON.parse(keyFile);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new Error('Failed to load the wallet. Invalid KeyFile!');
|
|
51
|
+
}
|
|
52
|
+
return sdk_wallet_1.UserSigner.fromWallet(keyFile, password);
|
|
53
|
+
}
|
|
54
|
+
async connectWallet(privateKey, options) {
|
|
55
|
+
// INFO: This method is overriden in the web sdk
|
|
56
|
+
// to connect with the extension wallet
|
|
57
|
+
this.wallet = await this.connectKeyFileWallet(privateKey, options?.password);
|
|
58
|
+
return this.wallet;
|
|
59
|
+
}
|
|
60
|
+
getAddress() {
|
|
61
|
+
// INFO: method is overriden in the web sdk
|
|
62
|
+
(0, core_1.required)(this.wallet, 'Wallet not connected');
|
|
63
|
+
if (this.wallet instanceof sdk_extension_provider_1.ExtensionProvider) {
|
|
64
|
+
return this.wallet.account.address;
|
|
65
|
+
}
|
|
66
|
+
else if (this.wallet instanceof sdk_wallet_1.UserSigner) {
|
|
67
|
+
return this.wallet.getAddress().bech32();
|
|
68
|
+
}
|
|
69
|
+
throw new Error("Unknown wallet type. Can't get address.");
|
|
70
|
+
}
|
|
71
|
+
// SECTION: Reads
|
|
72
|
+
async getBalance(address) {
|
|
73
|
+
(0, core_1.required)(address, 'address is required to get the balance');
|
|
74
|
+
const Iaddress = new sdk_core_1.Address(address);
|
|
75
|
+
const account = await this.provider.getAccount(Iaddress);
|
|
76
|
+
return account.balance.toString();
|
|
77
|
+
}
|
|
78
|
+
async getTokenBalance(token_id) {
|
|
79
|
+
(0, core_1.required)(this.provider);
|
|
80
|
+
(0, core_1.required)(this.wallet);
|
|
81
|
+
const walletAddress = this.getAddress();
|
|
82
|
+
const address = new sdk_core_1.Address(walletAddress);
|
|
83
|
+
const token = await this.provider.getFungibleTokenOfAccount(address, token_id);
|
|
84
|
+
return token.balance.toNumber();
|
|
85
|
+
}
|
|
86
|
+
async getNFTs() {
|
|
87
|
+
(0, core_1.required)(this.provider);
|
|
88
|
+
(0, core_1.required)(this.wallet);
|
|
89
|
+
const address = this.getAddress();
|
|
90
|
+
const account = new sdk_core_1.Address(address);
|
|
91
|
+
return this.provider.getNonFungibleTokensOfAccount(account);
|
|
92
|
+
}
|
|
93
|
+
// /**
|
|
94
|
+
// * Connect a Multiversx wallet. Pass the `keyFile` JSON string as the `privateKey` and its `password` to override the De-Fi wallet prompt.
|
|
95
|
+
// */
|
|
96
|
+
// async connectWallet(
|
|
97
|
+
// privateKey?: string,
|
|
98
|
+
// options?: {
|
|
99
|
+
// password: string;
|
|
100
|
+
// }
|
|
101
|
+
// ) {
|
|
102
|
+
// if (privateKey && options?.password) {
|
|
103
|
+
// return this.connectKeyFileWallet(privateKey, options.password);
|
|
104
|
+
// }
|
|
105
|
+
// this.wallet = ExtensionProvider.getInstance();
|
|
106
|
+
// await this.wallet.init();
|
|
107
|
+
// // INFO: wallet.isInitialized() checks if the wallet is installed.
|
|
108
|
+
// // It's equivalent to checking for `window.elrondWallet` object which is injected by the extension
|
|
109
|
+
// // LINK to src: https://github.com/multiversx/mx-sdk-js-extension-provider/blob/36518d0fe0b295de8d2b977727f0c30cdc014c78/src/extensionProvider.ts#L45
|
|
110
|
+
// if (!this.wallet.isInitialized()) {
|
|
111
|
+
// throw new Error('Wallet not detected. Is the MultiversX DeFi Wallet extension installed?');
|
|
112
|
+
// }
|
|
113
|
+
// await this.wallet.login();
|
|
114
|
+
// return this.wallet.isConnected();
|
|
115
|
+
// }
|
|
116
|
+
// SECTION: Writes
|
|
117
|
+
/**
|
|
118
|
+
* Signs a single transaction. Calls `signTransactions` with a single transaction and returns the first element of the result.
|
|
119
|
+
* @returns The signed transaction as a plain object
|
|
120
|
+
*/
|
|
121
|
+
async signTransaction(transaction, options) {
|
|
122
|
+
const txs = await this.signTransactions([transaction], options);
|
|
123
|
+
return txs[0];
|
|
124
|
+
}
|
|
125
|
+
async addTxNonces(transactions) {
|
|
126
|
+
(0, core_1.required)(this.provider, 'Provider not connected');
|
|
127
|
+
// INFO: Override wallet connection
|
|
128
|
+
// if (options?.privateKey) {
|
|
129
|
+
// await this.connectWallet(options.privateKey, {
|
|
130
|
+
// password: options.password,
|
|
131
|
+
// })
|
|
132
|
+
// }
|
|
133
|
+
// INFO: Retrieve account on network to get nonce
|
|
134
|
+
const senderBech32 = this.getAddress();
|
|
135
|
+
const senderAddress = new sdk_core_1.Address(senderBech32);
|
|
136
|
+
const account = new sdk_core_1.Account(senderAddress);
|
|
137
|
+
const senderOnNetwork = await this.provider.getAccount(senderAddress);
|
|
138
|
+
account.update(senderOnNetwork);
|
|
139
|
+
// INFO: Local nonce management
|
|
140
|
+
// LINK: https://docs.multiversx.com/integrators/creating-transactions/#nonce-management
|
|
141
|
+
let currentNonce = account.nonce.valueOf();
|
|
142
|
+
transactions.forEach((tx) => {
|
|
143
|
+
tx.setNonce(currentNonce);
|
|
144
|
+
// INFO: Increment the nonce for the next tx
|
|
145
|
+
currentNonce++;
|
|
146
|
+
});
|
|
147
|
+
return transactions;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Signs multiple transactions
|
|
151
|
+
* @returns The signed transactions as an array of plain objects
|
|
152
|
+
*/
|
|
153
|
+
async signTransactions(transactions, options) {
|
|
154
|
+
(0, core_1.required)(this.wallet || options?.privateKey, 'Wallet not connected');
|
|
155
|
+
// INFO: Override wallet connection
|
|
156
|
+
if (options?.privateKey) {
|
|
157
|
+
await this.connectWallet(options.privateKey, {
|
|
158
|
+
password: options.password,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// INFO: Retrieve account on network to get nonce
|
|
162
|
+
// const senderBech32 = this.getAddress()
|
|
163
|
+
// const senderAddress = new Address(senderBech32)
|
|
164
|
+
// const account = new Account(senderAddress)
|
|
165
|
+
// const senderOnNetwork = await this.provider.getAccount(senderAddress)
|
|
166
|
+
// account.update(senderOnNetwork)
|
|
167
|
+
// // INFO: Local nonce management
|
|
168
|
+
// // LINK: https://docs.multiversx.com/integrators/creating-transactions/#nonce-management
|
|
169
|
+
// let currentNonce = account.nonce.valueOf()
|
|
170
|
+
// transactions.forEach((tx) => {
|
|
171
|
+
// tx.setNonce(currentNonce)
|
|
172
|
+
// // INFO: Increment the nonce for the next tx
|
|
173
|
+
// currentNonce++
|
|
174
|
+
// })
|
|
175
|
+
transactions = await this.addTxNonces(transactions);
|
|
176
|
+
// try {
|
|
177
|
+
// // INFO: When wallet is loaded from Extension
|
|
178
|
+
// transactions = await (
|
|
179
|
+
// this.wallet as ExtensionProvider
|
|
180
|
+
// ).signTransactions(transactions)
|
|
181
|
+
// } catch (error) {
|
|
182
|
+
for (const tx of transactions) {
|
|
183
|
+
const serializedTx = tx.serializeForSigning();
|
|
184
|
+
const txSign = await this.wallet.sign(serializedTx);
|
|
185
|
+
tx.applySignature(txSign);
|
|
186
|
+
}
|
|
187
|
+
// }
|
|
188
|
+
return transactions.map((tx) => {
|
|
189
|
+
// INFO: Return plain objects
|
|
190
|
+
return tx.toSendable();
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
async preparePay(address, amount) {
|
|
194
|
+
const txs = await this.preparePays([{ address, amount }]);
|
|
195
|
+
return txs[0];
|
|
196
|
+
}
|
|
197
|
+
async preparePays(payments) {
|
|
198
|
+
(0, core_1.required)(this.wallet);
|
|
199
|
+
const sender = this.getAddress();
|
|
200
|
+
const senderAddress = new sdk_core_1.Address(sender);
|
|
201
|
+
const transactions = payments.map((payment) => {
|
|
202
|
+
const transfer = sdk_core_1.TokenTransfer.egldFromAmount(payment.amount);
|
|
203
|
+
const receiverAddress = new sdk_core_1.Address(payment.address);
|
|
204
|
+
const factory = new sdk_core_1.TransferTransactionsFactory(new sdk_core_1.GasEstimator());
|
|
205
|
+
return factory.createEGLDTransfer({
|
|
206
|
+
value: transfer,
|
|
207
|
+
sender: senderAddress,
|
|
208
|
+
receiver: receiverAddress,
|
|
209
|
+
chainID: this.chainId,
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
return this.signTransactions(transactions);
|
|
213
|
+
}
|
|
214
|
+
prepareTransfer(receiver, amount) {
|
|
215
|
+
return this.preparePay(receiver, amount);
|
|
216
|
+
}
|
|
217
|
+
prepareTransfers(tranfers) {
|
|
218
|
+
return this.preparePays(tranfers);
|
|
219
|
+
}
|
|
220
|
+
async disconnect() {
|
|
221
|
+
this.resetInstance();
|
|
222
|
+
return !this.connected;
|
|
223
|
+
}
|
|
224
|
+
// SECTION Unimplemented methods
|
|
225
|
+
getEmptyTransaction() {
|
|
226
|
+
throw new Error('Method not implemented.');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.MULTIVERSX = MULTIVERSX;
|
|
230
|
+
//# sourceMappingURL=multiversx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversx.js","sourceRoot":"","sources":["../../../../src/multichain/core/multiversx.ts"],"names":[],"mappings":";;;AAAA,mDAQ6B;AAC7B,+EAAsE;AACtE,6EAAsE;AAEtE,uDAAmD;AAEnD,4CAK0B;AAE1B,MAAa,UAAW,SAAQ,mBAAY;IAKxC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;QAHlB,YAAO,GAAW,EAAE,CAAA;QAIhB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAA;QA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;YAEnE,OAAO,OAAO,CAAC,kBAAkB,CAAC;gBAC9B,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,aAAa;gBACrB,QAAQ,EAAE,eAAe;gBACzB,OAAO,EAAE,IAAI,CAAC,OAAO;aACxB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAA;IAC9C,CAAC;IAED,eAAe,CAAC,QAAgB,EAAE,MAAc;QAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;IAED,gBAAgB,CAAC,QAAuB;QACpC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;IAED,KAAK,CAAC,UAAU;QACZ,IAAI,CAAC,aAAa,EAAE,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAA;IAC1B,CAAC;IAED,gCAAgC;IAChC,mBAAmB;QACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;CACJ;AAhSD,gCAgSC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Contract, TransactionReceipt } from 'ethers';
|
|
2
|
+
import { IBCConnectWalletOptions, IPayOptions } from './interfaces';
|
|
3
|
+
export declare abstract class DefaultChain {
|
|
4
|
+
provider: any;
|
|
5
|
+
name: string;
|
|
6
|
+
signer: any;
|
|
7
|
+
wallet: any;
|
|
8
|
+
rpc_url: string;
|
|
9
|
+
connected: boolean;
|
|
10
|
+
constructor(rpc_url: string);
|
|
11
|
+
/**
|
|
12
|
+
* Sets the RPC URL only. Use `await instance.connect()` to connect to the rpc provider
|
|
13
|
+
* @param rpc_url
|
|
14
|
+
*/
|
|
15
|
+
setRpc(rpc_url: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new instance of this sdk
|
|
18
|
+
* @param rpc_url The RPC URL
|
|
19
|
+
* @returns The sdk instance connected to the RPC provider
|
|
20
|
+
*/
|
|
21
|
+
static create<T extends DefaultChain>(this: new (rpc_url: string) => T, rpc_url?: string): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Resets the instance provider, wallet and rpc_url
|
|
24
|
+
*/
|
|
25
|
+
protected resetInstance(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Connects to the RPC provider
|
|
28
|
+
* @returns A boolean indicating if the connection was successful
|
|
29
|
+
*/
|
|
30
|
+
abstract connect(): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Disconnects from the RPC provider and the wallet
|
|
33
|
+
* @returns A boolean indicating if the disconnection was successful
|
|
34
|
+
*/
|
|
35
|
+
abstract disconnect(): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Connects to a wallet using a private key
|
|
38
|
+
* @param privateKey The private key of the wallet
|
|
39
|
+
* @returns The wallet object
|
|
40
|
+
*/
|
|
41
|
+
abstract connectWallet(privateKey: string, options?: {}): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the balance of a wallet
|
|
44
|
+
* @param address The wallet address
|
|
45
|
+
* @param options Options
|
|
46
|
+
* @returns The balance of the wallet as a string
|
|
47
|
+
*/
|
|
48
|
+
abstract getBalance(address: string, options?: {}): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a signed transaction to transfer default chain currency
|
|
51
|
+
* @param receiver The receiver's address
|
|
52
|
+
* @param amount The amount to transfer
|
|
53
|
+
* @param options Options
|
|
54
|
+
* @returns The signed transaction
|
|
55
|
+
*/
|
|
56
|
+
abstract preparePay(receiver: string, amount: string, options: {}): Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a signed transaction to transfer default chain currency
|
|
59
|
+
* @param receiver The receiver's address
|
|
60
|
+
* @param amount The amount to transfer
|
|
61
|
+
* @param options Options
|
|
62
|
+
* @returns The signed transaction
|
|
63
|
+
*/
|
|
64
|
+
abstract prepareTransfer(receiver: string, amount: string, options: {}): Promise<any>;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a list of signed transactions to transfer default chain currency
|
|
67
|
+
* @param payments A list of transfers to prepare
|
|
68
|
+
* @param options Options
|
|
69
|
+
* @returns An ordered list of signed transactions
|
|
70
|
+
*/
|
|
71
|
+
abstract preparePays(payments: IPayOptions[], options: {}): Promise<any[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a list of signed transactions to transfer default chain currency
|
|
74
|
+
* @param payments A list of transfers to prepare
|
|
75
|
+
* @param options Options
|
|
76
|
+
* @returns An ordered list of signed transactions
|
|
77
|
+
*/
|
|
78
|
+
abstract prepareTransfers(payments: IPayOptions[], options: {}): Promise<any[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a skeleton transaction
|
|
81
|
+
*/
|
|
82
|
+
abstract getEmptyTransaction(): any;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the address of the connected wallet
|
|
85
|
+
*/
|
|
86
|
+
abstract getAddress(): string;
|
|
87
|
+
/**
|
|
88
|
+
* Signs a transaction using the connected wallet
|
|
89
|
+
* @param raw_transaction The transaction to sign
|
|
90
|
+
* @param options Options
|
|
91
|
+
* @returns The signed transaction
|
|
92
|
+
*/
|
|
93
|
+
abstract signTransaction(raw_transaction: any, options?: {
|
|
94
|
+
privateKey?: string;
|
|
95
|
+
}): Promise<any>;
|
|
96
|
+
/**
|
|
97
|
+
* Signs a list of transactions using the connected wallet. The transaction nonce is incremented for each transaction in order of appearance.
|
|
98
|
+
*
|
|
99
|
+
* @param transactions A list of transactions to sign
|
|
100
|
+
* @param options Options
|
|
101
|
+
*/
|
|
102
|
+
abstract signTransactions(transactions: any[], options?: {
|
|
103
|
+
privateKey?: string;
|
|
104
|
+
}): Promise<any[]>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Interface for web sdk exclusive methods
|
|
108
|
+
*/
|
|
109
|
+
export interface IDefaultChainWeb extends DefaultChain {
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Interface for local sdk exclusive methods
|
|
113
|
+
*/
|
|
114
|
+
export interface IDefaultChainLocal extends DefaultChain {
|
|
115
|
+
/**
|
|
116
|
+
* Gets various infos
|
|
117
|
+
*/
|
|
118
|
+
getInfo: () => Promise<any>;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a new wallet
|
|
121
|
+
* @param password The password to encrypt the wallet
|
|
122
|
+
*/
|
|
123
|
+
createWallet: (password: string) => Promise<any>;
|
|
124
|
+
/**
|
|
125
|
+
* Broadcasts a signed transaction
|
|
126
|
+
* @param tx The signed transaction
|
|
127
|
+
* @returns The transaction hash
|
|
128
|
+
*/
|
|
129
|
+
sendTransaction: (signed_tx: any) => Promise<any>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Base methods for the EVM Default Chain SDK
|
|
133
|
+
*/
|
|
134
|
+
export interface IEVMDefaultChain {
|
|
135
|
+
contracts: Map<string, Contract>;
|
|
136
|
+
isEIP1559: boolean;
|
|
137
|
+
chainId: number;
|
|
138
|
+
prepareBaseTxWithType: () => Promise<any>;
|
|
139
|
+
getContractInstance: (address: string, abi: string) => Promise<Contract>;
|
|
140
|
+
createRawTransaction: (tx_data: any) => Promise<any>;
|
|
141
|
+
readFromContract: (contract: any, method: string, args: any) => Promise<any>;
|
|
142
|
+
writeToContract: (contract: any, method: string, args: any) => Promise<any>;
|
|
143
|
+
listenForEvent: (event: string, contract: string, abi: any[]) => Promise<any>;
|
|
144
|
+
listenForAllEvents: (contract: string, abi: any[]) => Promise<any>;
|
|
145
|
+
waitForReceipt: (tx_hash: string) => Promise<TransactionReceipt>;
|
|
146
|
+
}
|
|
147
|
+
export interface IBCDefaultChain extends DefaultChain {
|
|
148
|
+
connectWallet(privateKey: string, options: IBCConnectWalletOptions): Promise<any>;
|
|
149
|
+
ibcSend: () => Promise<any>;
|
|
150
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultChain = void 0;
|
|
4
|
+
class DefaultChain {
|
|
5
|
+
// NOTE We init chain with await CHAIN.create(rpc_url)
|
|
6
|
+
// This is necessary to ensure that the provider is connected
|
|
7
|
+
// if the user specifies the rpc_url in the constructor,
|
|
8
|
+
// as we cannot use await in the constructor
|
|
9
|
+
constructor(rpc_url) {
|
|
10
|
+
this.provider = null;
|
|
11
|
+
this.name = '';
|
|
12
|
+
this.signer = null;
|
|
13
|
+
this.wallet = null;
|
|
14
|
+
this.rpc_url = '';
|
|
15
|
+
this.connected = false;
|
|
16
|
+
this.setRpc(rpc_url);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Sets the RPC URL only. Use `await instance.connect()` to connect to the rpc provider
|
|
20
|
+
* @param rpc_url
|
|
21
|
+
*/
|
|
22
|
+
setRpc(rpc_url) {
|
|
23
|
+
this.rpc_url = rpc_url;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new instance of this sdk
|
|
27
|
+
* @param rpc_url The RPC URL
|
|
28
|
+
* @returns The sdk instance connected to the RPC provider
|
|
29
|
+
*/
|
|
30
|
+
static async create(rpc_url = '') {
|
|
31
|
+
const instance = new this(rpc_url);
|
|
32
|
+
instance.setRpc(rpc_url);
|
|
33
|
+
if (rpc_url) {
|
|
34
|
+
await instance.connect();
|
|
35
|
+
}
|
|
36
|
+
return instance;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resets the instance provider, wallet and rpc_url
|
|
40
|
+
*/
|
|
41
|
+
resetInstance() {
|
|
42
|
+
this.provider = null;
|
|
43
|
+
this.wallet = null;
|
|
44
|
+
this.signer = null;
|
|
45
|
+
this.connected = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.DefaultChain = DefaultChain;
|
|
49
|
+
//# sourceMappingURL=defaultChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultChain.js","sourceRoot":"","sources":["../../../../../src/multichain/core/types/defaultChain.ts"],"names":[],"mappings":";;;AAGA,MAAsB,YAAY;IAQ9B,sDAAsD;IACtD,6DAA6D;IAC7D,wDAAwD;IACxD,4CAA4C;IAC5C,YAAY,OAAe;QAX3B,aAAQ,GAAQ,IAAI,CAAA;QACpB,SAAI,GAAW,EAAE,CAAA;QACjB,WAAM,GAAQ,IAAI,CAAA;QAClB,WAAM,GAAQ,IAAI,CAAA;QAClB,YAAO,GAAW,EAAE,CAAA;QACpB,cAAS,GAAY,KAAK,CAAA;QAOtB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACxB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAe;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAEf,UAAkB,EAAE;QAEpB,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;QAClC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAExB,IAAI,OAAO,EAAE,CAAC;YACV,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAA;QAC5B,CAAC;QAED,OAAO,QAAQ,CAAA;IACnB,CAAC;IAED;;OAEG;IACO,aAAa;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;IAC1B,CAAC;CA6GJ;AAhKD,oCAgKC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { MsgSendEncodeObject, StdFee } from '@cosmjs/stargate';
|
|
2
|
+
/**
|
|
3
|
+
* `preparePay` parameters
|
|
4
|
+
*/
|
|
5
|
+
export interface IPayOptions {
|
|
6
|
+
address: string;
|
|
7
|
+
amount: number | string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The response of a XM transaction
|
|
11
|
+
*/
|
|
12
|
+
export interface TransactionResponse {
|
|
13
|
+
/**
|
|
14
|
+
* Whether the transaction was successful or not
|
|
15
|
+
*/
|
|
16
|
+
result: 'success' | 'error';
|
|
17
|
+
/**
|
|
18
|
+
* The hash of the transaction if the tx was successful
|
|
19
|
+
*/
|
|
20
|
+
hash?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The error object if the tx failed
|
|
23
|
+
*/
|
|
24
|
+
error?: any;
|
|
25
|
+
/**
|
|
26
|
+
* The chain where the transaction was executed
|
|
27
|
+
*/
|
|
28
|
+
chain?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Extra optional data about the transaction extracted from the response.
|
|
31
|
+
* Currently available for XRPL transactions
|
|
32
|
+
*/
|
|
33
|
+
extra?: {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface EGLDSignTxOptions {
|
|
38
|
+
/**
|
|
39
|
+
* The private key to override the connected wallet
|
|
40
|
+
*/
|
|
41
|
+
privateKey: string;
|
|
42
|
+
/**
|
|
43
|
+
* The password of the override wallet
|
|
44
|
+
*/
|
|
45
|
+
password: string;
|
|
46
|
+
}
|
|
47
|
+
export interface IBCTransaction {
|
|
48
|
+
signerAddress: string;
|
|
49
|
+
messages: MsgSendEncodeObject[];
|
|
50
|
+
fee: StdFee | null;
|
|
51
|
+
memo: string;
|
|
52
|
+
}
|
|
53
|
+
export interface IBCConnectWalletOptions {
|
|
54
|
+
/**
|
|
55
|
+
* The address prefix
|
|
56
|
+
*/
|
|
57
|
+
prefix: string;
|
|
58
|
+
/**
|
|
59
|
+
* The the price of a single unit of gas. This is typically a fraction of the smallest fee token unit, such as 0.012utoken
|
|
60
|
+
*/
|
|
61
|
+
gasPrice: string;
|
|
62
|
+
/**
|
|
63
|
+
* The multiplier to apply to the estimated gas price. Used to make sure transactions do not run out of gas.
|
|
64
|
+
*
|
|
65
|
+
* @default 2.0
|
|
66
|
+
*/
|
|
67
|
+
multiplier?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface IBCGetBalanceOptions {
|
|
70
|
+
/**
|
|
71
|
+
* The denomination of the token
|
|
72
|
+
*/
|
|
73
|
+
denom: string;
|
|
74
|
+
}
|
|
75
|
+
export interface IBCPreparePayOptions extends IBCGetBalanceOptions {
|
|
76
|
+
}
|
|
77
|
+
export interface IBCSignTxOptions extends IBCConnectWalletOptions {
|
|
78
|
+
/**
|
|
79
|
+
* The private key to override the connected wallet
|
|
80
|
+
*/
|
|
81
|
+
privateKey?: string;
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/multichain/core/types/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throw an error if a value is nullish
|
|
3
|
+
*
|
|
4
|
+
* @param {any} value The value to check
|
|
5
|
+
* @param {string} msg The help text on error
|
|
6
|
+
* @param {boolean} fatal should we raise an error? Default: `true`
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare function required(value: any, msg?: string, fatal?: boolean): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.required = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Throw an error if a value is nullish
|
|
6
|
+
*
|
|
7
|
+
* @param {any} value The value to check
|
|
8
|
+
* @param {string} msg The help text on error
|
|
9
|
+
* @param {boolean} fatal should we raise an error? Default: `true`
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
function required(value, msg = 'Missing required element', fatal = true) {
|
|
13
|
+
// INFO: Copied from node repo
|
|
14
|
+
if (!value) {
|
|
15
|
+
if (fatal)
|
|
16
|
+
throw new Error('[REQUIRED] ' + msg);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
exports.required = required;
|
|
22
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/multichain/core/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,SAAgB,QAAQ,CACpB,KAAU,EACV,MAAc,0BAA0B,EACxC,QAAiB,IAAI;IAErB,8BAA8B;IAE9B,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,IAAI,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,aAAa,GAAG,GAAG,CAAC,CAAA;QAC/C,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,OAAO,IAAI,CAAA;AACf,CAAC;AAbD,4BAaC"}
|