@kynesyslabs/demosdk 1.0.30 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/multichain/core/ten.d.ts +0 -1
- package/build/multichain/core/ten.js +1 -5
- package/build/multichain/core/ten.js.map +1 -1
- package/build/multichain/core/ton.d.ts +17 -0
- package/build/multichain/core/ton.js +90 -0
- package/build/multichain/core/ton.js.map +1 -0
- package/build/multichain/core/types/defaultChain.d.ts +18 -36
- package/build/multichain/core/types/defaultChain.js +39 -1
- package/build/multichain/core/types/defaultChain.js.map +1 -1
- package/build/types/blockchain/blocks.d.ts +2 -0
- package/build/types/blockchain/encryptedTransaction.d.ts +8 -0
- package/build/types/blockchain/encryptedTransaction.js +3 -0
- package/build/types/blockchain/encryptedTransaction.js.map +1 -0
- package/build/types/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -64,7 +64,7 @@ class TEN extends defaultChain_1.DefaultChain {
|
|
|
64
64
|
signer = web3.eth.accounts.privateKeyToAccount(options.privateKey);
|
|
65
65
|
}
|
|
66
66
|
// INFO: Get account nonce
|
|
67
|
-
const nonce = await this.provider.getTransactionCount(signer.address,
|
|
67
|
+
const nonce = await this.provider.getTransactionCount(signer.address, "pending");
|
|
68
68
|
console.log("ledger nonce: ", nonce);
|
|
69
69
|
//INFO: Max safe integer: 9007199254740991
|
|
70
70
|
let currentNonce = (0, web3_utils_1.toNumber)(nonce);
|
|
@@ -112,10 +112,6 @@ class TEN extends defaultChain_1.DefaultChain {
|
|
|
112
112
|
const balance = await this.provider.getBalance(address);
|
|
113
113
|
return (0, web3_utils_1.toNumber)(balance).toString();
|
|
114
114
|
}
|
|
115
|
-
async disconnect() {
|
|
116
|
-
this.resetInstance();
|
|
117
|
-
return this.connected;
|
|
118
|
-
}
|
|
119
115
|
getEmptyTransaction() {
|
|
120
116
|
return this.prepareBaseTransaction();
|
|
121
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ten.js","sourceRoot":"","sources":["../../../../src/multichain/core/ten.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;
|
|
1
|
+
{"version":3,"file":"ten.js","sourceRoot":"","sources":["../../../../src/multichain/core/ten.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAG5B,uDAAmD;AAEnD,mCAAkC;AAClC,2CAA4C;AAE5C,MAAa,GAAI,SAAQ,2BAAY;IAKjC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAE9C,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;YAChD,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;YAC3C,IAAI,CAAC,SAAS,GAAG,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAA;QACrD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;QAC1B,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,UAAkB;QAClC,gEAAgE;QAChE,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC;YACpC,CAAC,CAAC,UAAU;YACZ,CAAC,CAAC,IAAI,GAAG,UAAU,CAAA;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;QAE/D,OAAO,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,UAAU;QACN,IAAA,g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;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC5B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QAEvD,OAAO,IAAA,qBAAQ,EAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;IACvC,CAAC;IAED,mBAAmB;QACf,OAAO,IAAI,CAAC,sBAAsB,EAAE,CAAA;IACxC,CAAC;CACJ;AA9HD,kBA8HC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { KeyPair } from "@ton/crypto";
|
|
3
|
+
import { Cell, TonClient } from "@ton/ton";
|
|
4
|
+
import { DefaultChain } from "./types/defaultChain";
|
|
5
|
+
import { IPayOptions } from ".";
|
|
6
|
+
export declare class TON extends DefaultChain {
|
|
7
|
+
provider: TonClient;
|
|
8
|
+
signer: KeyPair;
|
|
9
|
+
constructor(rpc_url: string);
|
|
10
|
+
connect(): Promise<boolean>;
|
|
11
|
+
connectWallet(mnemonics: string, options?: {}): Promise<KeyPair>;
|
|
12
|
+
getAddress(): string;
|
|
13
|
+
getBalance(address: string): Promise<string>;
|
|
14
|
+
signTransactions(txs: Cell[]): Promise<Cell[]>;
|
|
15
|
+
preparePays(payments: IPayOptions[], options: {}): Promise<Buffer[]>;
|
|
16
|
+
getEmptyTransaction(): Promise<import("@ton/ton").Builder>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TON = void 0;
|
|
7
|
+
const crypto_1 = require("@ton/crypto");
|
|
8
|
+
const ton_1 = require("@ton/ton");
|
|
9
|
+
const defaultChain_1 = require("./types/defaultChain");
|
|
10
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
11
|
+
class TON extends defaultChain_1.DefaultChain {
|
|
12
|
+
constructor(rpc_url) {
|
|
13
|
+
super(rpc_url);
|
|
14
|
+
this.name = "ton";
|
|
15
|
+
}
|
|
16
|
+
async connect() {
|
|
17
|
+
this.provider = new ton_1.TonClient({
|
|
18
|
+
endpoint: this.rpc_url,
|
|
19
|
+
});
|
|
20
|
+
try {
|
|
21
|
+
const info = await this.provider.getMasterchainInfo();
|
|
22
|
+
console.log(info);
|
|
23
|
+
this.connected = !!info;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error(error);
|
|
27
|
+
this.connected = false;
|
|
28
|
+
}
|
|
29
|
+
return this.connected;
|
|
30
|
+
}
|
|
31
|
+
async connectWallet(mnemonics, options) {
|
|
32
|
+
this.signer = await (0, crypto_1.mnemonicToPrivateKey)(mnemonics.split(" "));
|
|
33
|
+
return this.signer;
|
|
34
|
+
}
|
|
35
|
+
// SECTION: Information
|
|
36
|
+
getAddress() {
|
|
37
|
+
const wallet = ton_1.WalletContractV4.create({
|
|
38
|
+
publicKey: this.signer.publicKey,
|
|
39
|
+
workchain: 0,
|
|
40
|
+
});
|
|
41
|
+
return wallet.address.toString();
|
|
42
|
+
}
|
|
43
|
+
async getBalance(address) {
|
|
44
|
+
const addr = ton_1.Address.parse(address);
|
|
45
|
+
const bal = await this.provider.getBalance(addr);
|
|
46
|
+
return new bignumber_js_1.default(bal).toString();
|
|
47
|
+
}
|
|
48
|
+
// SECTION: Transactions
|
|
49
|
+
async signTransactions(txs) {
|
|
50
|
+
// TODO: Test this method
|
|
51
|
+
// NOTE: preparePay signs the tx so this method is not used
|
|
52
|
+
return txs.map(tx => {
|
|
53
|
+
const signature = (0, crypto_1.sign)(txs[0].hash(), this.signer.secretKey);
|
|
54
|
+
return (0, ton_1.beginCell)()
|
|
55
|
+
.storeBuffer(signature)
|
|
56
|
+
.storeBuilder(tx.asBuilder())
|
|
57
|
+
.endCell();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async preparePays(payments, options) {
|
|
61
|
+
const wallet = ton_1.WalletContractV4.create({
|
|
62
|
+
publicKey: this.signer.publicKey,
|
|
63
|
+
workchain: 0,
|
|
64
|
+
});
|
|
65
|
+
wallet.address;
|
|
66
|
+
const contract = this.provider.open(wallet);
|
|
67
|
+
const seqNo = await contract.getSeqno();
|
|
68
|
+
console.log("seqNo: ", seqNo);
|
|
69
|
+
const txs = payments.map(payment => {
|
|
70
|
+
return contract
|
|
71
|
+
.createTransfer({
|
|
72
|
+
seqno: seqNo,
|
|
73
|
+
secretKey: this.signer.secretKey,
|
|
74
|
+
messages: [
|
|
75
|
+
(0, ton_1.internal)({
|
|
76
|
+
value: (0, ton_1.toNano)(payment.amount),
|
|
77
|
+
to: payment.address,
|
|
78
|
+
}),
|
|
79
|
+
],
|
|
80
|
+
})
|
|
81
|
+
.toBoc();
|
|
82
|
+
});
|
|
83
|
+
return txs;
|
|
84
|
+
}
|
|
85
|
+
async getEmptyTransaction() {
|
|
86
|
+
return (0, ton_1.beginCell)();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.TON = TON;
|
|
90
|
+
//# sourceMappingURL=ton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ton.js","sourceRoot":"","sources":["../../../../src/multichain/core/ton.ts"],"names":[],"mappings":";;;;;;AAAA,wCAAiE;AACjE,kCAQiB;AAEjB,uDAAmD;AAEnD,gEAAoC;AAEpC,MAAa,GAAI,SAAQ,2BAAY;IAIjC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAS,CAAC;YAC1B,QAAQ,EAAE,IAAI,CAAC,OAAO;SACzB,CAAC,CAAA;QAEF,IAAI,CAAC;YACD,MAAM,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
|
|
@@ -25,15 +25,29 @@ export declare abstract class DefaultChain {
|
|
|
25
25
|
*/
|
|
26
26
|
protected resetInstance(): void;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
28
|
+
* Creates a signed transaction to transfer default chain currency
|
|
29
|
+
* @param receiver The receiver's address
|
|
30
|
+
* @param amount The amount to transfer
|
|
31
|
+
* @param options Options
|
|
32
|
+
* @returns The signed transaction
|
|
30
33
|
*/
|
|
31
|
-
|
|
34
|
+
prepareTransfer<T extends DefaultChain>(this: T, receiver: string, amount: string, options?: {}): Promise<Awaited<ReturnType<T["preparePays"]>>[number]>;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a list of signed transactions to transfer default chain currency
|
|
37
|
+
* @param payments A list of transfers to prepare
|
|
38
|
+
* @param options Options
|
|
39
|
+
* @returns An ordered list of signed transactions
|
|
40
|
+
*/
|
|
41
|
+
prepareTransfers<T extends DefaultChain>(this: T, payments: IPayParams[], options?: {}): Promise<Awaited<ReturnType<T["preparePays"]>>>;
|
|
32
42
|
/**
|
|
33
43
|
* Disconnects from the RPC provider and the wallet
|
|
34
44
|
* @returns A boolean indicating if the disconnection was successful
|
|
35
45
|
*/
|
|
36
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Connects to the RPC provider
|
|
48
|
+
* @returns A boolean indicating if the connection was successful
|
|
49
|
+
*/
|
|
50
|
+
abstract connect(): Promise<boolean>;
|
|
37
51
|
/**
|
|
38
52
|
* Connects to a wallet using a private key
|
|
39
53
|
* @param privateKey The private key of the wallet
|
|
@@ -47,22 +61,6 @@ export declare abstract class DefaultChain {
|
|
|
47
61
|
* @returns The balance of the wallet as a string
|
|
48
62
|
*/
|
|
49
63
|
abstract getBalance(address: string, options?: {}): Promise<string>;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a signed transaction to transfer default chain currency
|
|
52
|
-
* @param receiver The receiver's address
|
|
53
|
-
* @param amount The amount to transfer
|
|
54
|
-
* @param options Options
|
|
55
|
-
* @returns The signed transaction
|
|
56
|
-
*/
|
|
57
|
-
abstract preparePay(receiver: string, amount: string, options: {}): Promise<any>;
|
|
58
|
-
/**
|
|
59
|
-
* Creates a signed transaction to transfer default chain currency
|
|
60
|
-
* @param receiver The receiver's address
|
|
61
|
-
* @param amount The amount to transfer
|
|
62
|
-
* @param options Options
|
|
63
|
-
* @returns The signed transaction
|
|
64
|
-
*/
|
|
65
|
-
prepareTransfer<T extends DefaultChain>(this: T, receiver: string, amount: string, options?: {}): ReturnType<T["preparePay"]>;
|
|
66
64
|
/**
|
|
67
65
|
* Creates a list of signed transactions to transfer default chain currency
|
|
68
66
|
* @param payments A list of transfers to prepare
|
|
@@ -70,13 +68,6 @@ export declare abstract class DefaultChain {
|
|
|
70
68
|
* @returns An ordered list of signed transactions
|
|
71
69
|
*/
|
|
72
70
|
abstract preparePays(payments: IPayParams[], options: {}): Promise<any[]>;
|
|
73
|
-
/**
|
|
74
|
-
* Creates a list of signed transactions to transfer default chain currency
|
|
75
|
-
* @param payments A list of transfers to prepare
|
|
76
|
-
* @param options Options
|
|
77
|
-
* @returns An ordered list of signed transactions
|
|
78
|
-
*/
|
|
79
|
-
prepareTransfers<T extends DefaultChain>(this: T, payments: IPayParams[], options?: {}): ReturnType<T["preparePays"]>;
|
|
80
71
|
/**
|
|
81
72
|
* Creates a skeleton transaction
|
|
82
73
|
*/
|
|
@@ -85,15 +76,6 @@ export declare abstract class DefaultChain {
|
|
|
85
76
|
* Returns the address of the connected wallet
|
|
86
77
|
*/
|
|
87
78
|
abstract getAddress(): string;
|
|
88
|
-
/**
|
|
89
|
-
* Signs a transaction using the connected wallet
|
|
90
|
-
* @param raw_transaction The transaction to sign
|
|
91
|
-
* @param options Options
|
|
92
|
-
* @returns The signed transaction
|
|
93
|
-
*/
|
|
94
|
-
abstract signTransaction(raw_transaction: any, options?: {
|
|
95
|
-
privateKey?: string;
|
|
96
|
-
}): Promise<any>;
|
|
97
79
|
/**
|
|
98
80
|
* Signs a list of transactions using the connected wallet. The transaction nonce is incremented for each transaction in order of appearance.
|
|
99
81
|
*
|
|
@@ -15,6 +15,7 @@ class DefaultChain {
|
|
|
15
15
|
this.connected = false;
|
|
16
16
|
this.setRpc(rpc_url);
|
|
17
17
|
}
|
|
18
|
+
// SECTION: Global methods
|
|
18
19
|
/**
|
|
19
20
|
* Sets the RPC URL only. Use `await instance.connect()` to connect to the rpc provider
|
|
20
21
|
* @param rpc_url
|
|
@@ -44,6 +45,44 @@ class DefaultChain {
|
|
|
44
45
|
this.signer = null;
|
|
45
46
|
this.connected = false;
|
|
46
47
|
}
|
|
48
|
+
// /**
|
|
49
|
+
// * Signs a transaction using the connected wallet
|
|
50
|
+
// * @param tx The transaction to sign
|
|
51
|
+
// * @param options Options
|
|
52
|
+
// * @returns The signed transaction
|
|
53
|
+
// */
|
|
54
|
+
// async signTransaction<
|
|
55
|
+
// T extends DefaultChain,
|
|
56
|
+
// Tx extends Parameters<T["signTransactions"]>[0][number],
|
|
57
|
+
// >(
|
|
58
|
+
// this: T,
|
|
59
|
+
// tx: Tx,
|
|
60
|
+
// options?: {},
|
|
61
|
+
// ): Promise<Awaited<ReturnType<T["preparePays"]>>[number]> {
|
|
62
|
+
// // INFO: The return type of this.signTransaction is the same as the return type of the first element of this.signTransactions
|
|
63
|
+
// // The type of the tx parameter is the same as the type of the first parameter of this.signTransactions
|
|
64
|
+
// const txs = await this.signTransactions([tx], options)
|
|
65
|
+
// return txs[0]
|
|
66
|
+
// }
|
|
67
|
+
// /**
|
|
68
|
+
// * Creates a signed transaction to transfer default chain currency
|
|
69
|
+
// * @param receiver The receiver's address
|
|
70
|
+
// * @param amount The amount to transfer
|
|
71
|
+
// * @param options Options
|
|
72
|
+
// * @returns The signed transaction
|
|
73
|
+
// */
|
|
74
|
+
// async preparePay<T extends DefaultChain>(
|
|
75
|
+
// this: T,
|
|
76
|
+
// receiver: string,
|
|
77
|
+
// amount: string,
|
|
78
|
+
// options?: {},
|
|
79
|
+
// ): Promise<Awaited<ReturnType<T["preparePays"]>>[number]> {
|
|
80
|
+
// const txs = await this.preparePays(
|
|
81
|
+
// [{ address: receiver, amount }],
|
|
82
|
+
// options,
|
|
83
|
+
// )
|
|
84
|
+
// return txs[0]
|
|
85
|
+
// }
|
|
47
86
|
/**
|
|
48
87
|
* Creates a signed transaction to transfer default chain currency
|
|
49
88
|
* @param receiver The receiver's address
|
|
@@ -53,7 +92,6 @@ class DefaultChain {
|
|
|
53
92
|
*/
|
|
54
93
|
prepareTransfer(receiver, amount, options) {
|
|
55
94
|
// @ts-expect-error
|
|
56
|
-
// INFO: Will throw error here because method is not implemented in the abstract class
|
|
57
95
|
return this.preparePay(receiver, amount, options);
|
|
58
96
|
}
|
|
59
97
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultChain.js","sourceRoot":"","sources":["../../../../../src/multichain/core/types/defaultChain.ts"],"names":[],"mappings":";;;AASA,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,QA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IAAI,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;IAC1B,CAAC;IAED,MAAM;IACN,oDAAoD;IACpD,uCAAuC;IACvC,4BAA4B;IAC5B,qCAAqC;IACrC,MAAM;IACN,yBAAyB;IACzB,8BAA8B;IAC9B,+DAA+D;IAC/D,KAAK;IACL,eAAe;IACf,cAAc;IACd,oBAAoB;IACpB,8DAA8D;IAC9D,oIAAoI;IACpI,8GAA8G;IAC9G,6DAA6D;IAC7D,oBAAoB;IACpB,IAAI;IAEJ,MAAM;IACN,qEAAqE;IACrE,4CAA4C;IAC5C,0CAA0C;IAC1C,4BAA4B;IAC5B,qCAAqC;IACrC,MAAM;IACN,4CAA4C;IAC5C,eAAe;IACf,wBAAwB;IACxB,sBAAsB;IACtB,oBAAoB;IACpB,8DAA8D;IAC9D,0CAA0C;IAC1C,2CAA2C;IAC3C,mBAAmB;IACnB,QAAQ;IAER,oBAAoB;IACpB,IAAI;IAEJ;;;;;;OAMG;IACH,eAAe,CAEX,QAAgB,EAChB,MAAc,EACd,OAAY;QAEZ,mBAAmB;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAEZ,QAAsB,EACtB,OAAY;QAEZ,mBAAmB;QACnB,sFAAsF;QACtF,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;CAoEJ;AAnMD,oCAmMC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { pki } from "node-forge";
|
|
2
|
+
import { EncryptedTransaction } from './encryptedTransaction';
|
|
2
3
|
export interface BlockContent {
|
|
3
4
|
ordered_transactions: string[];
|
|
5
|
+
encrypted_transactions: EncryptedTransaction[];
|
|
4
6
|
per_address_transactions: Map<string, string[]>;
|
|
5
7
|
web2data: {};
|
|
6
8
|
previousHash: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryptedTransaction.js","sourceRoot":"","sources":["../../../../src/types/blockchain/encryptedTransaction.ts"],"names":[],"mappings":""}
|
package/build/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { TxFee } from './blockchain/TxFee';
|
|
|
4
4
|
export { CValidityData, ValidityData } from './blockchain/ValidityData';
|
|
5
5
|
export { BlockContent, Block } from './blockchain/blocks';
|
|
6
6
|
export { Transaction, TransactionContent, XMPayload, Web2Payload, NativePayload, StringifiedPayload } from './blockchain/Transaction';
|
|
7
|
+
export { EncryptedTransaction } from './blockchain/encryptedTransaction';
|
|
7
8
|
export { RawTransaction } from './blockchain/rawTransaction';
|
|
8
9
|
export { Bundle, BundleContent } from './communication/transmit';
|
|
9
10
|
export { AddressInfo } from './blockchain/addressInfo';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kynesyslabs/demosdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"author": "Kynesys Labs",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@multiversx/sdk-extension-provider": "^3.0.0",
|
|
29
29
|
"@multiversx/sdk-network-providers": "^2.4.3",
|
|
30
30
|
"@multiversx/sdk-wallet": "^4.4.0",
|
|
31
|
+
"@orbs-network/ton-access": "^2.3.3",
|
|
31
32
|
"@project-serum/anchor": "^0.26.0",
|
|
32
33
|
"@solana/buffer-layout": "^4.0.1",
|
|
33
34
|
"@solana/web3.js": "^1.91.7",
|