@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,54 @@
|
|
|
1
|
+
import { Client, Transaction, Wallet } from 'xrpl';
|
|
2
|
+
import { DefaultChain, IPayOptions } from './';
|
|
3
|
+
/**
|
|
4
|
+
* Get the last sequence number of an address
|
|
5
|
+
* @param address The address
|
|
6
|
+
* @returns The last sequence number
|
|
7
|
+
*/
|
|
8
|
+
export declare function xrplGetLastSequence(provider: Client, address: string): Promise<number>;
|
|
9
|
+
export declare class XRPL extends DefaultChain {
|
|
10
|
+
provider: Client;
|
|
11
|
+
wallet: Wallet;
|
|
12
|
+
constructor(rpc_url: string);
|
|
13
|
+
setRPC(rpc_url: string): Promise<void>;
|
|
14
|
+
connect(with_reconnect?: boolean): Promise<boolean>;
|
|
15
|
+
connectWallet(privateKey: string): Promise<Wallet>;
|
|
16
|
+
getAddress(): string;
|
|
17
|
+
getBalance(address: string, multi?: boolean): Promise<string>;
|
|
18
|
+
signTransaction(transaction: Transaction, options?: {
|
|
19
|
+
privateKey: string;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
tx_blob: string;
|
|
22
|
+
hash: string;
|
|
23
|
+
}>;
|
|
24
|
+
signTransactions(transactions: Transaction[], options?: {
|
|
25
|
+
privateKey: string;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
tx_blob: string;
|
|
28
|
+
hash: string;
|
|
29
|
+
}[]>;
|
|
30
|
+
preparePay(address: string, amount: number | string): Promise<{
|
|
31
|
+
tx_blob: string;
|
|
32
|
+
hash: string;
|
|
33
|
+
}>;
|
|
34
|
+
preparePays(payments: IPayOptions[]): Promise<{
|
|
35
|
+
tx_blob: string;
|
|
36
|
+
hash: string;
|
|
37
|
+
}[]>;
|
|
38
|
+
prepareTransfer(address: any, amount: any): Promise<{
|
|
39
|
+
tx_blob: string;
|
|
40
|
+
hash: string;
|
|
41
|
+
}>;
|
|
42
|
+
prepareTransfers(payments: IPayOptions[]): Promise<{
|
|
43
|
+
tx_blob: string;
|
|
44
|
+
hash: string;
|
|
45
|
+
}[]>;
|
|
46
|
+
getEmptyTransaction(): Promise<{
|
|
47
|
+
TransactionType: "Payment";
|
|
48
|
+
Account: string;
|
|
49
|
+
Amount: string;
|
|
50
|
+
Destination: string;
|
|
51
|
+
Sequence: number;
|
|
52
|
+
}>;
|
|
53
|
+
disconnect(): Promise<boolean>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XRPL = exports.xrplGetLastSequence = void 0;
|
|
4
|
+
const xrpl_1 = require("xrpl");
|
|
5
|
+
const core_1 = require("./");
|
|
6
|
+
/**
|
|
7
|
+
* Get the last sequence number of an address
|
|
8
|
+
* @param address The address
|
|
9
|
+
* @returns The last sequence number
|
|
10
|
+
*/
|
|
11
|
+
async function xrplGetLastSequence(provider, address) {
|
|
12
|
+
// INFO: Get user's current sequence
|
|
13
|
+
// Code extracted from the xrpl library
|
|
14
|
+
// By following this.provider.autofill
|
|
15
|
+
const request = {
|
|
16
|
+
command: 'account_info',
|
|
17
|
+
account: address,
|
|
18
|
+
ledger_index: 'current',
|
|
19
|
+
};
|
|
20
|
+
const account_info = await provider.request(request);
|
|
21
|
+
const currentSequence = account_info.result.account_data.Sequence;
|
|
22
|
+
return currentSequence;
|
|
23
|
+
}
|
|
24
|
+
exports.xrplGetLastSequence = xrplGetLastSequence;
|
|
25
|
+
class XRPL extends core_1.DefaultChain {
|
|
26
|
+
constructor(rpc_url) {
|
|
27
|
+
super(rpc_url);
|
|
28
|
+
this.name = 'xrpl';
|
|
29
|
+
if (rpc_url) {
|
|
30
|
+
this.setRPC(rpc_url);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// SECTION: Providers
|
|
34
|
+
// INFO Set of methods for connecting to an RPC while
|
|
35
|
+
// retaining a granular control over the instance status
|
|
36
|
+
async setRPC(rpc_url) {
|
|
37
|
+
this.provider = new xrpl_1.Client(rpc_url, {
|
|
38
|
+
connectionTimeout: 10000,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async connect(with_reconnect = true) {
|
|
42
|
+
// INFO Connects to the provider with error handling
|
|
43
|
+
let trial_index = 0;
|
|
44
|
+
let maxTrials = 3;
|
|
45
|
+
const providerConnect = async () => {
|
|
46
|
+
try {
|
|
47
|
+
await this.provider.connect();
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
trial_index++;
|
|
52
|
+
if (trial_index == maxTrials) {
|
|
53
|
+
// INFO: Return false if we failed to connect
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// INFO: Retry for the Nth time
|
|
57
|
+
await providerConnect();
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
};
|
|
61
|
+
// Listen for connection events
|
|
62
|
+
this.provider.on('connected', () => {
|
|
63
|
+
console.log('Successfully connected to XRPL.');
|
|
64
|
+
this.connected = true;
|
|
65
|
+
});
|
|
66
|
+
// Handle disconnection events
|
|
67
|
+
// INFO: with_reconnect = false is used to exit tests without open handles
|
|
68
|
+
if (with_reconnect) {
|
|
69
|
+
this.provider.on('disconnected', async (code) => {
|
|
70
|
+
// Handle the disconnection event (e.g., attempt to reconnect)
|
|
71
|
+
console.log(`Disconnected from XRPL with code: ${code}, reconnecting: ${with_reconnect}`);
|
|
72
|
+
this.connected = false;
|
|
73
|
+
this.connected = await providerConnect();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// Handle errors
|
|
77
|
+
this.provider.on('error', (errorCode, errorMessage, data) => {
|
|
78
|
+
console.log(`XRPL Client Error: ${errorCode}, ${errorMessage}`);
|
|
79
|
+
// Handle the error based on errorCode and errorMessage
|
|
80
|
+
});
|
|
81
|
+
// Finally, connect to the provider
|
|
82
|
+
this.connected = await providerConnect();
|
|
83
|
+
return this.connected;
|
|
84
|
+
}
|
|
85
|
+
// static override async create(rpc_url: string) {
|
|
86
|
+
// const instance = new XRPL(rpc_url)
|
|
87
|
+
// // instance.setRpc(rpc_url)
|
|
88
|
+
// if (rpc_url) {
|
|
89
|
+
// await instance.connect('')
|
|
90
|
+
// }
|
|
91
|
+
// return instance
|
|
92
|
+
// }
|
|
93
|
+
// SECTION: Wallets
|
|
94
|
+
// INFO Connecting a wallet through a private key (string)
|
|
95
|
+
async connectWallet(privateKey) {
|
|
96
|
+
this.wallet = xrpl_1.Wallet.fromSeed(privateKey);
|
|
97
|
+
return this.wallet;
|
|
98
|
+
}
|
|
99
|
+
getAddress() {
|
|
100
|
+
return this.wallet.address;
|
|
101
|
+
}
|
|
102
|
+
// SECTION: Reads
|
|
103
|
+
// REVIEW: getBalance return type. Should it be a string or an object?
|
|
104
|
+
async getBalance(address, multi = true) {
|
|
105
|
+
let response = null;
|
|
106
|
+
if (multi) {
|
|
107
|
+
response = await this.provider.getBalances(address);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
response = await this.provider.getXrpBalance(address);
|
|
111
|
+
}
|
|
112
|
+
// @ts-expect-error
|
|
113
|
+
return response;
|
|
114
|
+
}
|
|
115
|
+
// SECTION: Writes
|
|
116
|
+
// INFO Signing a transaction
|
|
117
|
+
// with a private key or by using our stored wallet
|
|
118
|
+
async signTransaction(transaction, options) {
|
|
119
|
+
// INFO: Call signTransactions with a single transaction
|
|
120
|
+
const txs = await this.signTransactions([transaction], options);
|
|
121
|
+
return txs[0];
|
|
122
|
+
}
|
|
123
|
+
async signTransactions(transactions, options) {
|
|
124
|
+
// INFO: If a private key is provided, override the wallet
|
|
125
|
+
// REVIEW: Should we assign the new wallet to this.wallet?
|
|
126
|
+
if (options?.privateKey) {
|
|
127
|
+
this.wallet = xrpl_1.Wallet.fromSeed(options.privateKey);
|
|
128
|
+
}
|
|
129
|
+
// INFO: Check if wallet is connected
|
|
130
|
+
(0, core_1.required)(this.wallet, 'Wallet not connected');
|
|
131
|
+
let currentSequence = await xrplGetLastSequence(this.provider, this.getAddress());
|
|
132
|
+
return transactions.map((tx) => {
|
|
133
|
+
tx.Sequence = currentSequence;
|
|
134
|
+
// INFO: Increment the sequence for the next transaction
|
|
135
|
+
currentSequence++;
|
|
136
|
+
// NOTE: this.wallet.sign is not async
|
|
137
|
+
return this.wallet.sign(tx);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async preparePay(address, amount) {
|
|
141
|
+
(0, core_1.required)(this.wallet, 'Wallet not connected');
|
|
142
|
+
// INFO: Call preparePays with a single payment
|
|
143
|
+
const txs = await this.preparePays([{ address, amount }]);
|
|
144
|
+
return txs[0];
|
|
145
|
+
}
|
|
146
|
+
async preparePays(payments) {
|
|
147
|
+
const base_tx = await this.getEmptyTransaction();
|
|
148
|
+
const txs = payments.map((payment) => {
|
|
149
|
+
// Copy the base tx
|
|
150
|
+
const tx = {
|
|
151
|
+
...base_tx,
|
|
152
|
+
// Set amount and destination
|
|
153
|
+
Destination: payment.address,
|
|
154
|
+
Amount: (0, xrpl_1.xrpToDrops)(payment.amount),
|
|
155
|
+
// INFO: Sequence number will be set by this.signTransactions
|
|
156
|
+
};
|
|
157
|
+
return tx;
|
|
158
|
+
});
|
|
159
|
+
// INFO: Return a list of signed transactions
|
|
160
|
+
return this.signTransactions(txs);
|
|
161
|
+
}
|
|
162
|
+
// INFO transfer and pay are the same
|
|
163
|
+
async prepareTransfer(address, amount) {
|
|
164
|
+
return this.preparePay(address, amount);
|
|
165
|
+
}
|
|
166
|
+
async prepareTransfers(payments) {
|
|
167
|
+
return this.preparePays(payments);
|
|
168
|
+
}
|
|
169
|
+
// SECTION: Utils
|
|
170
|
+
// INFO Generic empty tx skeleton for this chain
|
|
171
|
+
async getEmptyTransaction() {
|
|
172
|
+
// INFO: Autofill the transaction
|
|
173
|
+
const tx = await this.provider.autofill({
|
|
174
|
+
TransactionType: 'Payment',
|
|
175
|
+
Account: this.getAddress(),
|
|
176
|
+
Amount: (0, xrpl_1.xrpToDrops)(0),
|
|
177
|
+
Destination: '',
|
|
178
|
+
Sequence: 0,
|
|
179
|
+
});
|
|
180
|
+
return tx;
|
|
181
|
+
}
|
|
182
|
+
async disconnect() {
|
|
183
|
+
await this.provider.disconnect();
|
|
184
|
+
this.resetInstance();
|
|
185
|
+
return !this.connected;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.XRPL = XRPL;
|
|
189
|
+
//# sourceMappingURL=xrp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xrp.js","sourceRoot":"","sources":["../../../../src/multichain/core/xrp.ts"],"names":[],"mappings":";;;AAAA,+BAMa;AAEb,4CAAuE;AAEvE;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CAAC,QAAgB,EAAE,OAAe;IACvE,oCAAoC;IACpC,uCAAuC;IACvC,sCAAsC;IACtC,MAAM,OAAO,GAAuB;QAChC,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,OAAO;QAChB,YAAY,EAAE,SAAS;KAC1B,CAAA;IAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACpD,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAA;IAEjE,OAAO,eAAe,CAAA;AAC1B,CAAC;AAdD,kDAcC;AAED,MAAa,IAAK,SAAQ,mBAAY;IAIlC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,MAAM,CAAA;QAElB,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;IACL,CAAC;IAED,qBAAqB;IAErB,qDAAqD;IACrD,wDAAwD;IACxD,KAAK,CAAC,MAAM,CAAC,OAAe;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAM,CAAC,OAAO,EAAE;YAChC,iBAAiB,EAAE,KAAK;SAC3B,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,iBAA0B,IAAI;QACxC,oDAAoD;QACpD,IAAI,WAAW,GAAG,CA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BAAU,EAAC,OAAO,CAAC,MAAM,CAAC;gBAClC,6DAA6D;aAChE,CAAA;YAED,OAAO,EAAE,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,6CAA6C;QAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC;IAED,qCAAqC;IACrC,KAAK,CAAC,eAAe,CAAC,OAAY,EAAE,MAAW;QAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAAuB;QAC1C,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;IAED,iBAAiB;IAEjB,gDAAgD;IAChD,KAAK,CAAC,mBAAmB;QACrB,iCAAiC;QACjC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACpC,eAAe,EAAE,SAAS;YAC1B,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,MAAM,EAAE,IAAA,iBAAU,EAAC,CAAC,CAAC;YACrB,WAAW,EAAE,EAAE;YACf,QAAQ,EAAE,CAAC;SACd,CAAC,CAAA;QAEF,OAAO,EAAE,CAAA;IACb,CAAC;IAED,KAAK,CAAC,UAAU;QACZ,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;QAChC,IAAI,CAAC,aAAa,EAAE,CAAA;QAEpB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAA;IAC1B,CAAC;CACJ;AA9ND,oBA8NC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.mxwebsdk = exports.mxcore = exports.mxlocalsdk = void 0;
|
|
27
|
+
exports.mxlocalsdk = __importStar(require("./localsdk"));
|
|
28
|
+
exports.mxcore = __importStar(require("./core"));
|
|
29
|
+
exports.mxwebsdk = __importStar(require("./websdk"));
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/multichain/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAwC;AACxC,iDAAgC;AAChC,qDAAoC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EVM as EVMCore, IDefaultChainLocal } from '../core';
|
|
2
|
+
import { TransactionRequest } from 'ethers';
|
|
3
|
+
export declare class EVM extends EVMCore implements IDefaultChainLocal {
|
|
4
|
+
private static instances;
|
|
5
|
+
constructor(rpc_url?: string, chainId?: number, eip1559?: boolean);
|
|
6
|
+
getInfo(): Promise<void>;
|
|
7
|
+
createWallet(password: string): Promise<void>;
|
|
8
|
+
sendRawTransaction(raw_tx: any): Promise<void>;
|
|
9
|
+
sendSignedTransaction(signed_tx: string): Promise<{
|
|
10
|
+
result: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
}>;
|
|
13
|
+
sendTransaction(tx: TransactionRequest): Promise<{
|
|
14
|
+
result: string;
|
|
15
|
+
hash: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* The static method that controls the access to the singleton instance.
|
|
19
|
+
*
|
|
20
|
+
* This implementation let you subclass the Singleton class while keeping
|
|
21
|
+
* just one instance of each subclass around.
|
|
22
|
+
*/
|
|
23
|
+
static getInstance(chain_id: number): EVM | null;
|
|
24
|
+
static createInstance(chain_id: number, rpc_url: string): EVM;
|
|
25
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVM = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
class EVM extends core_1.EVM {
|
|
6
|
+
constructor(rpc_url = '', chainId = 11155111, eip1559 = true) {
|
|
7
|
+
super(rpc_url, eip1559, chainId);
|
|
8
|
+
}
|
|
9
|
+
async getInfo() {
|
|
10
|
+
throw new Error('Method not implemented.');
|
|
11
|
+
}
|
|
12
|
+
async createWallet(password) {
|
|
13
|
+
throw new Error('Method not implemented.');
|
|
14
|
+
}
|
|
15
|
+
async sendRawTransaction(raw_tx) {
|
|
16
|
+
throw new Error('Method not implemented.');
|
|
17
|
+
}
|
|
18
|
+
async sendSignedTransaction(signed_tx) {
|
|
19
|
+
(0, core_1.required)(this.provider, 'Provider not connected');
|
|
20
|
+
const res = await this.provider.broadcastTransaction(signed_tx);
|
|
21
|
+
return {
|
|
22
|
+
result: 'success',
|
|
23
|
+
hash: res.hash,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async sendTransaction(tx) {
|
|
27
|
+
(0, core_1.required)(this.wallet, 'Wallet not connected');
|
|
28
|
+
const txResponse = await this.wallet.sendTransaction(tx); // NOTE It will be signed automatically
|
|
29
|
+
return {
|
|
30
|
+
result: 'success',
|
|
31
|
+
hash: txResponse.hash,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The static method that controls the access to the singleton instance.
|
|
36
|
+
*
|
|
37
|
+
* This implementation let you subclass the Singleton class while keeping
|
|
38
|
+
* just one instance of each subclass around.
|
|
39
|
+
*/
|
|
40
|
+
// INFO Getting an instance (if it exists) or false so that we can call createInstance
|
|
41
|
+
static getInstance(chain_id) {
|
|
42
|
+
if (!EVM.instances.get(chain_id)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return EVM.instances.get(chain_id) || null;
|
|
46
|
+
}
|
|
47
|
+
// INFO Creating an instance from a rpc url if not already created
|
|
48
|
+
static createInstance(chain_id, rpc_url) {
|
|
49
|
+
if (!EVM.instances.get(chain_id)) {
|
|
50
|
+
EVM.instances.set(chain_id, new EVM(rpc_url, chain_id));
|
|
51
|
+
}
|
|
52
|
+
const instance = EVM.instances.get(chain_id);
|
|
53
|
+
if (instance) {
|
|
54
|
+
return instance;
|
|
55
|
+
}
|
|
56
|
+
throw new Error('Could not create instance');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.EVM = EVM;
|
|
60
|
+
EVM.instances = new Map();
|
|
61
|
+
//# sourceMappingURL=evm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.js","sourceRoot":"","sources":["../../../../src/multichain/localsdk/evm.ts"],"names":[],"mappings":";;;AAAA,4CAAgF;AAGhF,MAAa,GAAI,SAAQ,UAAO;IAG5B,YACI,UAAkB,EAAE,EACpB,UAAkB,QAAQ,EAC1B,UAAmB,IAAI;QAEvB,KAAK,CAAC,OAAO,EAAE,OAAO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CAAC,QAAgB,EAAE,OAAe;QAC1D,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;QAC3D,CAAC;QAED,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAE5C,IAAI,QAAQ,EAAE,CAAC;YACX,OAAO,QAAQ,CAAA;QACnB,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAChD,CAAC;;AAxEL,kBAyEC;AAxEkB,aAAS,GAAqB,IAAI,GAAG,EAAe,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IBC as IBCCore, IDefaultChainLocal } from '../core';
|
|
2
|
+
export declare class IBC extends IBCCore implements IDefaultChainLocal {
|
|
3
|
+
constructor(rpc_url: string);
|
|
4
|
+
sendTransaction(signed_tx: Uint8Array): Promise<{
|
|
5
|
+
hash: string;
|
|
6
|
+
result: string;
|
|
7
|
+
}>;
|
|
8
|
+
getInfo(): Promise<string>;
|
|
9
|
+
createWallet(password?: string): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IBC = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
class IBC extends core_1.IBC {
|
|
6
|
+
constructor(rpc_url) {
|
|
7
|
+
super(rpc_url);
|
|
8
|
+
}
|
|
9
|
+
async sendTransaction(signed_tx) {
|
|
10
|
+
(0, core_1.required)(this.wallet, 'Wallet not connected');
|
|
11
|
+
const hash = await this.wallet.broadcastTxSync(signed_tx);
|
|
12
|
+
return {
|
|
13
|
+
hash,
|
|
14
|
+
result: 'success',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
async getInfo() {
|
|
18
|
+
throw new Error('Method not implemented.');
|
|
19
|
+
}
|
|
20
|
+
async createWallet(password) {
|
|
21
|
+
throw new Error('Method not implemented.');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.IBC = IBC;
|
|
25
|
+
//# sourceMappingURL=ibc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ibc.js","sourceRoot":"","sources":["../../../../src/multichain/localsdk/ibc.ts"],"names":[],"mappings":";;;AAAA,4CAAgF;AAEhF,MAAa,GAAI,SAAQ,UAAO;IAC5B,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,SAAqB;QACvC,IAAA,eAAQ,EAAC,IAAI,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;QAE7C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;QACzD,OAAO;YACH,IAAI;YACJ,MAAM,EAAE,SAAS;SACpB,CAAA;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACT,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAiB;QAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;CACJ;AAtBD,kBAsBC"}
|
|
@@ -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/localsdk/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,16 @@
|
|
|
1
|
+
import { MULTIVERSX as EGLDCore, IDefaultChainLocal } from '../core';
|
|
2
|
+
import { IPlainTransactionObject, Transaction } from '@multiversx/sdk-core';
|
|
3
|
+
export declare class MULTIVERSX extends EGLDCore implements IDefaultChainLocal {
|
|
4
|
+
constructor(rpc_url: string);
|
|
5
|
+
getInfo(): Promise<void>;
|
|
6
|
+
createWallet(password: string, addressIndex?: number): Promise<{
|
|
7
|
+
mnemonics: string[];
|
|
8
|
+
address: string;
|
|
9
|
+
mnemonics_txt: string;
|
|
10
|
+
wallet_keyfile: string;
|
|
11
|
+
}>;
|
|
12
|
+
sendTransaction(raw_tx: Transaction | IPlainTransactionObject): Promise<{
|
|
13
|
+
result: string;
|
|
14
|
+
hash: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MULTIVERSX = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
const sdk_core_1 = require("@multiversx/sdk-core");
|
|
6
|
+
const sdk_wallet_1 = require("@multiversx/sdk-wallet");
|
|
7
|
+
class MULTIVERSX extends core_1.MULTIVERSX {
|
|
8
|
+
constructor(rpc_url) {
|
|
9
|
+
super(rpc_url);
|
|
10
|
+
}
|
|
11
|
+
async getInfo() {
|
|
12
|
+
throw new Error('Method not implemented.');
|
|
13
|
+
}
|
|
14
|
+
async createWallet(password, addressIndex) {
|
|
15
|
+
(0, core_1.required)(password, 'Password is required to encrypt the key file');
|
|
16
|
+
const mnemonics = sdk_wallet_1.Mnemonic.generate();
|
|
17
|
+
const words = mnemonics.getWords();
|
|
18
|
+
const words_with_index = words.map((word, index) => index + '. ' + word);
|
|
19
|
+
const secretKey = mnemonics.deriveKey(addressIndex, password);
|
|
20
|
+
const wallet = sdk_wallet_1.UserWallet.fromSecretKey({ secretKey, password });
|
|
21
|
+
const jsonWallet = wallet.toJSON();
|
|
22
|
+
// NOTE: .bech32 is the address property
|
|
23
|
+
const walletAddress = jsonWallet.bech32;
|
|
24
|
+
// TODO Return downloadable mnemonics & json files
|
|
25
|
+
return {
|
|
26
|
+
mnemonics: words,
|
|
27
|
+
address: walletAddress,
|
|
28
|
+
mnemonics_txt: words_with_index.join(''),
|
|
29
|
+
wallet_keyfile: JSON.stringify(jsonWallet, null, 2),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async sendTransaction(raw_tx) {
|
|
33
|
+
(0, core_1.required)(this.provider, 'Provider not connected');
|
|
34
|
+
let signed_tx;
|
|
35
|
+
// INFO: raw_tx is a plain object when it comes from the frontend
|
|
36
|
+
if (!(raw_tx instanceof sdk_core_1.Transaction)) {
|
|
37
|
+
signed_tx = sdk_core_1.Transaction.fromPlainObject(raw_tx);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
signed_tx = raw_tx;
|
|
41
|
+
}
|
|
42
|
+
// INFO: The provider can also send a list of transactions
|
|
43
|
+
const tx_hash = await this.provider.sendTransaction(signed_tx);
|
|
44
|
+
return {
|
|
45
|
+
result: 'success',
|
|
46
|
+
hash: tx_hash,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.MULTIVERSX = MULTIVERSX;
|
|
51
|
+
//# sourceMappingURL=multiversx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiversx.js","sourceRoot":"","sources":["../../../../src/multichain/localsdk/multiversx.ts"],"names":[],"mappings":";;;AAAA,4CAI0B;AAE1B,mDAA2E;AAC3E,uDAA6D;AAE7D,MAAa,UAAW,SAAQ,iBAAQ;IACpC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,YAAqB;QACtD,IAAA,eAAQ,EAAC,QAAQ,EAAE,8CAA8C,CAAC,CAAA;QAElE,MAAM,SAAS,GAAG,qBAAQ,CAAC,QAAQ,EAAE,CAAA;QAErC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAA;QAClC,MAAM,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC,CAAA;QAExE,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;QAC7D,MAAM,MAAM,GAAG,uBAAU,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAA;QAEhE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,CAAA;QAElC,wCAAwC;QACxC,MAAM,aAAa,GAAW,UAAU,CAAC,MAAM,CAAA;QAE/C,kDAAkD;QAClD,OAAO;YACH,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,aAAa;YACtB,aAAa,EAAE,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;SACtD,CAAA;IACL,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAA6C;QAC/D,IAAA,eAAQ,EAAC,IAAI,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAA;QACjD,IAAI,SAAsB,CAAA;QAE1B,iEAAiE;QACjE,IAAI,CAAC,CAAC,MAAM,YAAY,sBAAW,CAAC,EAAE,CAAC;YACnC,SAAS,GAAG,sBAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QACnD,CAAC;aAAM,CAAC;YACJ,SAAS,GAAG,MAAM,CAAA;QACtB,CAAC;QAED,0DAA0D;QAC1D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAC/C,SAAwB,CAC3B,CAAA;QAED,OAAO;YACH,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,OAAO;SAChB,CAAA;IACL,CAAC;CACJ;AAvDD,gCAuDC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IDefaultChainLocal, XRPL as XRPLSdkCore } from '../core';
|
|
2
|
+
import * as xrpl from 'xrpl';
|
|
3
|
+
export declare class XRPL extends XRPLSdkCore implements IDefaultChainLocal {
|
|
4
|
+
constructor(rpc_url: string);
|
|
5
|
+
createWallet(password: string): Promise<void>;
|
|
6
|
+
getInfo(): Promise<void>;
|
|
7
|
+
accountInfo(address: string): Promise<xrpl.AccountInfoResponse>;
|
|
8
|
+
sendTransaction(signed: any, wait?: boolean): Promise<{
|
|
9
|
+
result: string;
|
|
10
|
+
hash: any;
|
|
11
|
+
extra?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
result: string;
|
|
14
|
+
hash: string | undefined;
|
|
15
|
+
extra: {
|
|
16
|
+
accepted: boolean;
|
|
17
|
+
result: string;
|
|
18
|
+
result_code: number;
|
|
19
|
+
result_message: string;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.XRPL = void 0;
|
|
27
|
+
const core_1 = require("../core");
|
|
28
|
+
const xrpl = __importStar(require("xrpl"));
|
|
29
|
+
class XRPL extends core_1.XRPL {
|
|
30
|
+
constructor(rpc_url) {
|
|
31
|
+
super(rpc_url);
|
|
32
|
+
}
|
|
33
|
+
// INFO Creates a new wallet
|
|
34
|
+
async createWallet(password) {
|
|
35
|
+
// TODO: Review this implementation
|
|
36
|
+
this.wallet = xrpl.Wallet.generate();
|
|
37
|
+
}
|
|
38
|
+
async getInfo() {
|
|
39
|
+
throw new Error('Method not implemented.');
|
|
40
|
+
}
|
|
41
|
+
// INFO Generic account info
|
|
42
|
+
async accountInfo(address) {
|
|
43
|
+
return await this.provider.request({
|
|
44
|
+
command: 'account_info',
|
|
45
|
+
account: address,
|
|
46
|
+
ledger_index: 'validated',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// INFO Generic sign, send and await (if not specified) a tx
|
|
50
|
+
async sendTransaction(signed, wait = false) {
|
|
51
|
+
// Sending the tx
|
|
52
|
+
console.log('[xrpl] sendtransaction');
|
|
53
|
+
if (wait) {
|
|
54
|
+
const res = await this.provider.submitAndWait(signed.tx_blob);
|
|
55
|
+
// NOTE: The return type here might need to change
|
|
56
|
+
return {
|
|
57
|
+
result: 'success',
|
|
58
|
+
hash: res.result.hash,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const res = await this.provider.submit(signed.tx_blob);
|
|
63
|
+
return {
|
|
64
|
+
result: res.result.accepted ? 'success' : 'error',
|
|
65
|
+
hash: res.result.tx_json.hash,
|
|
66
|
+
extra: {
|
|
67
|
+
accepted: res.result.accepted,
|
|
68
|
+
result: res.result.engine_result,
|
|
69
|
+
result_code: res.result.engine_result_code,
|
|
70
|
+
result_message: res.result.engine_result_message,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.XRPL = XRPL;
|
|
77
|
+
//# sourceMappingURL=xrp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xrp.js","sourceRoot":"","sources":["../../../../src/multichain/localsdk/xrp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA2E;AAC3E,2CAA4B;AAE5B,MAAa,IAAK,SAAQ,WAAW;IACjC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAED,4BAA4B;IAC5B,KAAK,CAAC,YAAY,CAAC,QAAgB;QAC/B,mCAAmC;QACnC,IAAI,CAAC,MAA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MAAM,CAAC,qBAAqB;iBACnD;aACJ,CAAA;QACL,CAAC;IACL,CAAC;CACJ;AApDD,oBAoDC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVM = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
class EVM extends core_1.EVM {
|
|
6
|
+
constructor(rpc_url) {
|
|
7
|
+
super(rpc_url);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.EVM = EVM;
|
|
11
|
+
//# sourceMappingURL=evm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.js","sourceRoot":"","sources":["../../../../src/multichain/websdk/evm.ts"],"names":[],"mappings":";;;AAAA,4CAAuE;AAEvE,MAAa,GAAI,SAAQ,UAAU;IAC/B,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;CAGJ;AAND,kBAMC"}
|