@poolstream/client 1.0.1 → 1.0.3-snapshot
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/dist/balance.d.ts +11 -0
- package/dist/currency-network-module.d.ts +9 -0
- package/dist/currency-network-module.js +3 -3
- package/dist/currency-network-module.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/info.d.ts +5 -0
- package/dist/network/ripple/ripple.d.ts +13 -0
- package/dist/network/ripple/ripple.js +1 -1
- package/dist/network/ripple/ripple.js.map +1 -1
- package/dist/network/solana/solana.d.ts +15 -0
- package/dist/network/solana/solana.js +1 -1
- package/dist/network/solana/solana.js.map +1 -1
- package/dist/network/stellar/stellar.d.ts +31 -0
- package/dist/network/stellar/stellar.js +3 -3
- package/dist/network/stellar/stellar.js.map +1 -1
- package/dist/network/tron/tron.d.ts +21 -0
- package/dist/network/tron/tron.js +3 -3
- package/dist/network/tron/tron.js.map +1 -1
- package/dist/network.d.ts +4 -0
- package/dist/poolstream.d.ts +50 -0
- package/dist/poolstream.js +8 -9
- package/dist/poolstream.js.map +1 -1
- package/dist/transaction.d.ts +22 -0
- package/dist/walletaddress.d.ts +7 -0
- package/package.json +2 -1
- package/src/balance.ts +4 -2
- package/src/currency-network-module.ts +3 -5
- package/src/network/ripple/ripple.ts +1 -1
- package/src/network/solana/solana.ts +1 -1
- package/src/network/stellar/stellar.ts +3 -3
- package/src/network/tron/tron.ts +3 -3
- package/src/poolstream.ts +13 -25
- package/src/transaction.ts +2 -2
- package/tsconfig.json +5 -4
@@ -0,0 +1,9 @@
|
|
1
|
+
import { SignebleTransaction } from "./transaction";
|
2
|
+
import { WalletAddress } from "./walletaddress";
|
3
|
+
export interface CurrencyNetworkModule {
|
4
|
+
signTransaction(transaction: SignebleTransaction): Promise<string>;
|
5
|
+
generateWalletAddress(): Promise<WalletAddress>;
|
6
|
+
readonly network: string;
|
7
|
+
}
|
8
|
+
export declare function getCoinNetworkModule(network: string, test?: boolean, generic?: boolean): CurrencyNetworkModule;
|
9
|
+
export declare const networks: any;
|
@@ -2,15 +2,15 @@ import { Ripple } from "./network/ripple/ripple";
|
|
2
2
|
import { Solana } from "./network/solana/solana";
|
3
3
|
import { Stellar } from "./network/stellar/stellar";
|
4
4
|
import { Tron } from "./network/tron/tron";
|
5
|
-
export function getCoinNetworkModule(network, test = false,
|
5
|
+
export function getCoinNetworkModule(network, test = false, generic = false) {
|
6
6
|
network = network.toLowerCase();
|
7
7
|
const nw = networks[network];
|
8
8
|
if (nw) {
|
9
|
-
const instanceCurrencyModule = nw.
|
9
|
+
const instanceCurrencyModule = nw.getModule(generic);
|
10
10
|
if (instanceCurrencyModule) {
|
11
11
|
return instanceCurrencyModule(test);
|
12
12
|
}
|
13
|
-
throw new Error(`
|
13
|
+
throw new Error(`Generic module of the [${network}] not available.`);
|
14
14
|
}
|
15
15
|
throw new Error(`Network [${network}] not available.`);
|
16
16
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"currency-network-module.js","sourceRoot":"","sources":["../src/currency-network-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAW3C,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,OAAgB,KAAK,EACrB,
|
1
|
+
{"version":3,"file":"currency-network-module.js","sourceRoot":"","sources":["../src/currency-network-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAW3C,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,OAAgB,KAAK,EACrB,UAAmB,KAAK;IAExB,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7B,IAAI,EAAE,EAAE,CAAC;QACP,MAAM,sBAAsB,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACrD,IAAI,sBAAsB,EAAE,CAAC;YAC3B,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,OAAO,kBAAkB,CAAC,CAAC;IACvE,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,kBAAkB,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAQ;IAC3B,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;CACf,CAAC"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
export { Transaction, SignebleTransaction, SubmittedTransaction, TransactionItem, } from "./transaction";
|
2
|
+
export { Network } from "./network";
|
3
|
+
export { CurrencyNetworkModule } from "./currency-network-module";
|
4
|
+
export { PoolStream, PoolStreamOptions } from "./poolstream";
|
5
|
+
export { WalletAddress } from "./walletaddress";
|
6
|
+
export { Balance } from "./balance";
|
7
|
+
export { Info } from "./info";
|
8
|
+
export { Ripple } from "./network/ripple/ripple";
|
package/dist/info.d.ts
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import { SignebleTransaction } from "../../transaction";
|
2
|
+
import { CurrencyNetworkModule } from "../../currency-network-module";
|
3
|
+
import { WalletAddress } from "../../walletaddress";
|
4
|
+
export declare abstract class Ripple implements CurrencyNetworkModule {
|
5
|
+
readonly network = "ripple";
|
6
|
+
constructor();
|
7
|
+
abstract signTransaction(transaction: SignebleTransaction): Promise<string>;
|
8
|
+
generateWalletAddress(): Promise<WalletAddress>;
|
9
|
+
}
|
10
|
+
export declare class XrpRipple extends Ripple {
|
11
|
+
constructor();
|
12
|
+
signTransaction(signebleTransaction: SignebleTransaction): Promise<string>;
|
13
|
+
}
|
@@ -27,7 +27,7 @@ export class XrpRipple extends Ripple {
|
|
27
27
|
super();
|
28
28
|
}
|
29
29
|
async signTransaction(signebleTransaction) {
|
30
|
-
const signTransactions = Promise.all(signebleTransaction.
|
30
|
+
const signTransactions = Promise.all(signebleTransaction.subs.map(async (item) => {
|
31
31
|
const seedWallet = Wallet.fromSeed(item.secret);
|
32
32
|
const Memos = item.extra ? item.extra.memos : undefined;
|
33
33
|
const Fee = signebleTransaction.fee
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ripple.js","sourceRoot":"","sources":["../../../src/network/ripple/ripple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,MAAM,CAAC;AAMvC,MAAM,OAAgB,MAAM;IAE1B;QADS,YAAO,GAAG,QAAQ,CAAC;IACb,CAAC;IAIhB,KAAK,CAAC,qBAAqB;QACzB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QACjC,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,cAAc;YAC9B,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU;YACrD,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,MAAM;SACZ,CAAC;IACJ,CAAC;CACF;AAED,8CAA8C;AAC9C,6EAA6E;AAC7E,uBAAuB;AACvB,MAAM;AAEN,+EAA+E;AAC/E,kDAAkD;AAClD,MAAM;AACN,IAAI;AAEJ,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC;QACE,KAAK,EAAE,CAAC;I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,GAAG,mBAAmB,CAAC,GAAG;gBACjC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,EAAE;gBACpC,CAAC,CAAC,SAAS,CAAC;YACd,MAAM,EAAE,GAAY;gBAClB,eAAe,EAAE,SAAS;gBAC1B,OAAO,EAAE,IAAI,CAAC,IAAI;gBAClB,WAAW,EAAE,IAAI,CAAC,EAAE;gBACpB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK;gBACL,GAAG;aACJ,CAAC;YAEF,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAErC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAChD,CAAC,CAAC,CACH,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAChD,CAAC;CACF"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { SignebleTransaction } from "../../transaction";
|
2
|
+
import { CurrencyNetworkModule } from "../../currency-network-module";
|
3
|
+
import { WalletAddress } from "../../walletaddress";
|
4
|
+
import { Connection } from "@solana/web3.js";
|
5
|
+
export declare abstract class Solana implements CurrencyNetworkModule {
|
6
|
+
readonly connection: Connection;
|
7
|
+
readonly network = "solana";
|
8
|
+
constructor(test?: boolean);
|
9
|
+
abstract signTransaction(transaction: SignebleTransaction): Promise<string>;
|
10
|
+
generateWalletAddress(): Promise<WalletAddress>;
|
11
|
+
}
|
12
|
+
export declare class SolSolana extends Solana {
|
13
|
+
constructor(test?: boolean);
|
14
|
+
signTransaction(signebleTransaction: SignebleTransaction): Promise<string>;
|
15
|
+
}
|
@@ -20,7 +20,7 @@ export class SolSolana extends Solana {
|
|
20
20
|
super(test);
|
21
21
|
}
|
22
22
|
async signTransaction(signebleTransaction) {
|
23
|
-
const signTransactions = Promise.all(signebleTransaction.
|
23
|
+
const signTransactions = Promise.all(signebleTransaction.subs.map(async (item) => {
|
24
24
|
const senderSecretKey = Uint8Array.from(Buffer.from(item.secret, "hex"));
|
25
25
|
const sender = Keypair.fromSecretKey(senderSecretKey);
|
26
26
|
const receiver = new PublicKey(item.to);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../src/network/solana/solana.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,UAAU,EACV,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAEzB,MAAM,OAAgB,MAAM;IAG1B,YAAY,OAAgB,KAAK;QADxB,YAAO,GAAG,QAAQ,CAAC;QAE1B,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAC9B,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAChD,CAAC;IACJ,CAAC;IAID,KAAK,CAAC,qBAAqB;QACzB,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAClC,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YACpC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;YACrD,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,MAAM;SACZ,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC,YAAY,OAAgB,KAAK;QAC/B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IACD,KAAK,CAAC,eAAe,CACnB,mBAAwC;QAExC,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAClC,mBAAmB,CAAC,
|
1
|
+
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../src/network/solana/solana.ts"],"names":[],"mappings":"AAKA,O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AS,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC;YACjE,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC,GAAG,CACvC,aAAa,CAAC,QAAQ,CAAC;gBACrB,UAAU,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;gBACpC,QAAQ,EAAE,QAAQ;gBAClB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;aAChC,CAAC,CACH,CAAC;YACF,WAAW,CAAC,eAAe,GAAG,SAAS,CAAC;YAExC,WAAW,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC;YAExC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEzB,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpD,CAAC,CAAC,CACH,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAChD,CAAC;CACF;AAED,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,OAAgB,KAAK,EAAE,EAAE,CAAC,IAAI,SAAS,EAAE,EAAE,CAAC"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Horizon } from "@stellar/stellar-sdk";
|
2
|
+
import { SignebleTransaction } from "../../transaction";
|
3
|
+
import { CurrencyNetworkModule } from "../../currency-network-module";
|
4
|
+
import { WalletAddress } from "../../walletaddress";
|
5
|
+
export declare abstract class Stellar implements CurrencyNetworkModule {
|
6
|
+
readonly server: Horizon.Server;
|
7
|
+
readonly network = "stellar";
|
8
|
+
constructor(test: boolean);
|
9
|
+
abstract signTransaction(transaction: SignebleTransaction): Promise<string>;
|
10
|
+
generateWalletAddress(): Promise<WalletAddress>;
|
11
|
+
}
|
12
|
+
export declare class GenericStellar extends Stellar {
|
13
|
+
protected readonly assetAddress: string;
|
14
|
+
constructor(assetAddress: string, test?: boolean);
|
15
|
+
test: {
|
16
|
+
signebleTransaction: {
|
17
|
+
fee: number;
|
18
|
+
items: {
|
19
|
+
from: string;
|
20
|
+
privateKey: string;
|
21
|
+
to: string;
|
22
|
+
amount: string;
|
23
|
+
}[];
|
24
|
+
};
|
25
|
+
};
|
26
|
+
signTransaction(transaction: SignebleTransaction): Promise<string>;
|
27
|
+
}
|
28
|
+
export declare class XlmStellar extends Stellar {
|
29
|
+
constructor(test?: boolean);
|
30
|
+
signTransaction(signebleTransaction: SignebleTransaction): Promise<string>;
|
31
|
+
}
|
@@ -38,10 +38,10 @@ export class GenericStellar extends Stellar {
|
|
38
38
|
};
|
39
39
|
}
|
40
40
|
async signTransaction(transaction) {
|
41
|
-
if (transaction.
|
41
|
+
if (transaction.subs.length < 0) {
|
42
42
|
throw new Error("Incomplete transaction.");
|
43
43
|
}
|
44
|
-
const result = await Promise.all(transaction.
|
44
|
+
const result = await Promise.all(transaction.subs.map(async (item) => {
|
45
45
|
const senderAccount = await this.server.loadAccount(item.from);
|
46
46
|
let transactionBuilder = new TransactionBuilder(senderAccount, {
|
47
47
|
fee: BASE_FEE,
|
@@ -73,7 +73,7 @@ export class XlmStellar extends Stellar {
|
|
73
73
|
super(test);
|
74
74
|
}
|
75
75
|
async signTransaction(signebleTransaction) {
|
76
|
-
const signTransactions = Promise.all(signebleTransaction.
|
76
|
+
const signTransactions = Promise.all(signebleTransaction.subs.map(async (item) => {
|
77
77
|
const account = await this.server.loadAccount(item.from);
|
78
78
|
let transactionBuilder = new TransactionBuilder(account, {
|
79
79
|
fee: BASE_FEE,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stellar.js","sourceRoot":"","sources":["../../../src/network/stellar/stellar.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,EACP,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAA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,KAAK,EAAE;iBACP,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,CACH,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAChD,CAAC;CACF"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { TronWeb, Contract } from "tronweb";
|
2
|
+
import { SignebleTransaction } from "../../transaction";
|
3
|
+
import { CurrencyNetworkModule } from "../../currency-network-module";
|
4
|
+
import { WalletAddress } from "../../walletaddress";
|
5
|
+
export declare abstract class Tron implements CurrencyNetworkModule {
|
6
|
+
readonly tronWeb: TronWeb;
|
7
|
+
constructor(test: boolean);
|
8
|
+
readonly network = "tron";
|
9
|
+
generateWalletAddress(): Promise<WalletAddress>;
|
10
|
+
abstract signTransaction(transaction: SignebleTransaction): Promise<string>;
|
11
|
+
}
|
12
|
+
export declare class GenericTron extends Tron {
|
13
|
+
readonly contractAddress: string;
|
14
|
+
usdtContract: Contract | null;
|
15
|
+
constructor(contractAddress: string, test?: boolean);
|
16
|
+
signTransaction(transaction: SignebleTransaction): Promise<string>;
|
17
|
+
}
|
18
|
+
export declare class TrxTron extends Tron {
|
19
|
+
constructor(test?: boolean);
|
20
|
+
signTransaction(signebleTransaction: SignebleTransaction): Promise<string>;
|
21
|
+
}
|
@@ -32,10 +32,10 @@ export class GenericTron extends Tron {
|
|
32
32
|
.contract()
|
33
33
|
.at(this.contractAddress);
|
34
34
|
}
|
35
|
-
if (transaction.
|
35
|
+
if (transaction.subs.length < 0) {
|
36
36
|
throw new Error("Incomplete transaction.");
|
37
37
|
}
|
38
|
-
const result = await Promise.all(transaction.
|
38
|
+
const result = await Promise.all(transaction.subs.map(async (item) => {
|
39
39
|
const from = item.from;
|
40
40
|
const parameter = [
|
41
41
|
{ type: "address", value: item.to },
|
@@ -53,7 +53,7 @@ export class TrxTron extends Tron {
|
|
53
53
|
super(test);
|
54
54
|
}
|
55
55
|
async signTransaction(signebleTransaction) {
|
56
|
-
const result = await Promise.all(signebleTransaction.
|
56
|
+
const result = await Promise.all(signebleTransaction.subs.map(async (item) => {
|
57
57
|
const transaction = await this.tronWeb.transactionBuilder.sendTrx(item.to, parseInt(item.amount), item.from);
|
58
58
|
return this.tronWeb.trx.sign(transaction, item.secret);
|
59
59
|
}));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tron.js","sourceRoot":"","sources":["../../../src/network/tron/tron.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAY,MAAM,SAAS,CAAC;AAKnD,MAAM,OAAgB,IAAI;IAGxB,YAAY,IAAa;QAQhB,YAAO,GAAG,MAAM,CAAC;QAPxB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC;YACzB,QAAQ,EAAE,IAAI;gBACZ,CAAC,CAAC,gCAAgC;gBAClC,CAAC,CAAC,yBAAyB;SAC9B,CAAC,CAAC;IACL,CAAC;IAID,KAAK,CAAC,qBAAqB;QACzB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;QAChD,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;YAC9B,MAAM,EAAE,MAAM,CAAC,UAAU;YACzB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,MAAM;SACZ,CAAC;IACJ,CAAC;CAGF;AAED,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AACtD,MAAM,OAAO,WAAY,SAAQ,IAAI;IAEnC,YAA4B,eAAuB,EAAE,OAAgB,KAAK;QACxE,KAAK,CAAC,IAAI,CAAC,CAAC;QADc,oBAAe,GAAf,eAAe,CAAQ;QADnD,iBAAY,GAAoB,IAAI,CAAC;IAGrC,CAAC;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d,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,mBAAwC;QAExC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAC1C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAC/D,IAAI,CAAC,EAAE,EACP,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EACrB,IAAI,CAAC,IAAI,CACV,CAAC;YACF,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC,CAAC,CACH,CAAC;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,CAAC;CACF"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { Balance } from "./balance";
|
2
|
+
import { SignebleTransaction, SubmittedTransaction } from "./transaction";
|
3
|
+
import { WalletAddress } from "./walletaddress";
|
4
|
+
export interface PoolStreamOptions {
|
5
|
+
apiKey?: string;
|
6
|
+
}
|
7
|
+
export interface TransactionFilter {
|
8
|
+
start?: number;
|
9
|
+
end?: number;
|
10
|
+
from?: string;
|
11
|
+
to?: string;
|
12
|
+
limit?: number;
|
13
|
+
}
|
14
|
+
export declare class PoolStream {
|
15
|
+
private url;
|
16
|
+
private options;
|
17
|
+
constructor(url: string, options?: PoolStreamOptions);
|
18
|
+
transaction(params: {
|
19
|
+
network: string;
|
20
|
+
txid: string;
|
21
|
+
}): Promise<SubmittedTransaction>;
|
22
|
+
info(params: {
|
23
|
+
network: string;
|
24
|
+
}): Promise<import("axios").AxiosResponse<any, any>>;
|
25
|
+
transactions(params: {
|
26
|
+
network: string;
|
27
|
+
filter?: TransactionFilter;
|
28
|
+
}): Promise<Array<SubmittedTransaction>>;
|
29
|
+
balances(params: {
|
30
|
+
network: string;
|
31
|
+
addresses: string | Array<string>;
|
32
|
+
}): Promise<Array<Balance>>;
|
33
|
+
networks(): Promise<Array<string>>;
|
34
|
+
submitTransaction(params: {
|
35
|
+
network: string;
|
36
|
+
signedTransaction: string;
|
37
|
+
}): Promise<Array<string>>;
|
38
|
+
signedAndSubmitTransaction(params: {
|
39
|
+
network: string;
|
40
|
+
transaction: SignebleTransaction;
|
41
|
+
contractAddress?: string;
|
42
|
+
}): Promise<Array<string>>;
|
43
|
+
signTransaction(params: {
|
44
|
+
network: string;
|
45
|
+
transaction: SignebleTransaction;
|
46
|
+
contractAddress?: string;
|
47
|
+
}): Promise<string>;
|
48
|
+
generateWalletAddress(network: string): Promise<WalletAddress>;
|
49
|
+
private apiKeyHeader;
|
50
|
+
}
|
package/dist/poolstream.js
CHANGED
@@ -5,11 +5,11 @@ export class PoolStream {
|
|
5
5
|
this.url = url;
|
6
6
|
this.options = options;
|
7
7
|
}
|
8
|
-
async transaction(
|
8
|
+
async transaction(params) {
|
9
9
|
return await axios({
|
10
10
|
method: "get",
|
11
11
|
headers: { ...this.apiKeyHeader() },
|
12
|
-
url: `${this.url}/auth/rest/v1/${
|
12
|
+
url: `${this.url}/auth/rest/v1/${params.network}/transaction/${params.txid}`,
|
13
13
|
responseType: "json",
|
14
14
|
});
|
15
15
|
}
|
@@ -29,7 +29,7 @@ export class PoolStream {
|
|
29
29
|
return await axios({
|
30
30
|
method: "get",
|
31
31
|
headers: { ...this.apiKeyHeader() },
|
32
|
-
url: `${this.url}/auth/rest/v1/${params.network}
|
32
|
+
url: `${this.url}/auth/rest/v1/${params.network}/transactions?${query}`,
|
33
33
|
responseType: "json",
|
34
34
|
});
|
35
35
|
}
|
@@ -46,14 +46,14 @@ export class PoolStream {
|
|
46
46
|
return await axios({
|
47
47
|
method: "get",
|
48
48
|
headers: { ...this.apiKeyHeader() },
|
49
|
-
url: `${this.url}/auth/rest/v1/${params.network}
|
49
|
+
url: `${this.url}/auth/rest/v1/${params.network}/balances${query}`,
|
50
50
|
responseType: "json",
|
51
51
|
});
|
52
52
|
}
|
53
53
|
async networks() {
|
54
54
|
return await axios({
|
55
55
|
method: "get",
|
56
|
-
url: `${this.url}/networks`,
|
56
|
+
url: `${this.url}/rest/v1/networks`,
|
57
57
|
responseType: "json",
|
58
58
|
});
|
59
59
|
}
|
@@ -61,21 +61,20 @@ export class PoolStream {
|
|
61
61
|
return await axios({
|
62
62
|
method: "post",
|
63
63
|
headers: { ...this.apiKeyHeader() },
|
64
|
-
url: `${this.url}/auth/rest/v1/${params.network}
|
64
|
+
url: `${this.url}/auth/rest/v1/${params.network}/submitSignedTransaction`,
|
65
65
|
responseType: "json",
|
66
66
|
data: { signedTransaction: params.signedTransaction },
|
67
67
|
});
|
68
68
|
}
|
69
69
|
async signedAndSubmitTransaction(params) {
|
70
|
-
const signedTransaction = await getCoinNetworkModule(params.network, false, params.contractAddress).signTransaction(params.transaction);
|
70
|
+
const signedTransaction = await getCoinNetworkModule(params.network, false, !!params.contractAddress).signTransaction(params.transaction);
|
71
71
|
return await this.submitTransaction({
|
72
72
|
network: params.network,
|
73
73
|
signedTransaction,
|
74
|
-
contractAddress: params.contractAddress,
|
75
74
|
});
|
76
75
|
}
|
77
76
|
async signTransaction(params) {
|
78
|
-
return await getCoinNetworkModule(params.network, false, params.contractAddress).signTransaction(params.transaction);
|
77
|
+
return await getCoinNetworkModule(params.network, false, !!params.contractAddress).signTransaction(params.transaction);
|
79
78
|
}
|
80
79
|
async generateWalletAddress(network) {
|
81
80
|
const walletAddress = await getCoinNetworkModule(network).generateWalletAddress();
|
package/dist/poolstream.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolstream.js","sourceRoot":"","sources":["../src/poolstream.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"poolstream.js","sourceRoot":"","sources":["../src/poolstream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC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
}
|
6
|
+
export interface SignebleTransaction extends Transaction {
|
7
|
+
subs: Array<TransactionItem & {
|
8
|
+
secret: string;
|
9
|
+
}>;
|
10
|
+
}
|
11
|
+
export interface TransactionItem {
|
12
|
+
from: string;
|
13
|
+
to: string;
|
14
|
+
amount: string;
|
15
|
+
extra?: any;
|
16
|
+
}
|
17
|
+
export interface SubmittedTransaction extends Transaction {
|
18
|
+
txID: string;
|
19
|
+
confirmations: number;
|
20
|
+
decimals: number;
|
21
|
+
timestamp: number;
|
22
|
+
}
|
package/package.json
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@poolstream/client",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3-snapshot",
|
4
4
|
"description": "To work with a collection of cryptocurrencies.",
|
5
5
|
"main": "dist/index.js",
|
6
|
+
"types": "dist/index.d.ts",
|
6
7
|
"private": false,
|
7
8
|
"scripts": {
|
8
9
|
"test": "npx jest",
|
package/src/balance.ts
CHANGED
@@ -15,18 +15,16 @@ export interface CurrencyNetworkModule {
|
|
15
15
|
export function getCoinNetworkModule(
|
16
16
|
network: string,
|
17
17
|
test: boolean = false,
|
18
|
-
|
18
|
+
generic: boolean = false
|
19
19
|
): CurrencyNetworkModule {
|
20
20
|
network = network.toLowerCase();
|
21
21
|
const nw = networks[network];
|
22
22
|
if (nw) {
|
23
|
-
const instanceCurrencyModule = nw.
|
23
|
+
const instanceCurrencyModule = nw.getModule(generic);
|
24
24
|
if (instanceCurrencyModule) {
|
25
25
|
return instanceCurrencyModule(test);
|
26
26
|
}
|
27
|
-
throw new Error(
|
28
|
-
`Contract Address [${contractAddress}]. Network [${network}] not available.`
|
29
|
-
);
|
27
|
+
throw new Error(`Generic module of the [${network}] not available.`);
|
30
28
|
}
|
31
29
|
throw new Error(`Network [${network}] not available.`);
|
32
30
|
}
|
@@ -40,7 +40,7 @@ export class XrpRipple extends Ripple {
|
|
40
40
|
signebleTransaction: SignebleTransaction
|
41
41
|
): Promise<string> {
|
42
42
|
const signTransactions = Promise.all(
|
43
|
-
signebleTransaction.
|
43
|
+
signebleTransaction.subs.map(async (item) => {
|
44
44
|
const seedWallet = Wallet.fromSeed(item.secret);
|
45
45
|
|
46
46
|
const Memos = item.extra ? item.extra.memos : undefined;
|
@@ -43,7 +43,7 @@ export class SolSolana extends Solana {
|
|
43
43
|
signebleTransaction: SignebleTransaction
|
44
44
|
): Promise<string> {
|
45
45
|
const signTransactions = Promise.all(
|
46
|
-
signebleTransaction.
|
46
|
+
signebleTransaction.subs.map(async (item) => {
|
47
47
|
const senderSecretKey = Uint8Array.from(
|
48
48
|
Buffer.from(item.secret, "hex")
|
49
49
|
);
|
@@ -62,11 +62,11 @@ export class GenericStellar extends Stellar {
|
|
62
62
|
};
|
63
63
|
|
64
64
|
async signTransaction(transaction: SignebleTransaction): Promise<string> {
|
65
|
-
if (transaction.
|
65
|
+
if (transaction.subs.length < 0) {
|
66
66
|
throw new Error("Incomplete transaction.");
|
67
67
|
}
|
68
68
|
const result = await Promise.all(
|
69
|
-
transaction.
|
69
|
+
transaction.subs.map(async (item) => {
|
70
70
|
const senderAccount = await this.server.loadAccount(item.from);
|
71
71
|
|
72
72
|
let transactionBuilder = new TransactionBuilder(senderAccount, {
|
@@ -113,7 +113,7 @@ export class XlmStellar extends Stellar {
|
|
113
113
|
signebleTransaction: SignebleTransaction
|
114
114
|
): Promise<string> {
|
115
115
|
const signTransactions = Promise.all(
|
116
|
-
signebleTransaction.
|
116
|
+
signebleTransaction.subs.map(async (item) => {
|
117
117
|
const account = await this.server.loadAccount(item.from);
|
118
118
|
let transactionBuilder = new TransactionBuilder(account, {
|
119
119
|
fee: BASE_FEE,
|
package/src/network/tron/tron.ts
CHANGED
@@ -43,11 +43,11 @@ export class GenericTron extends Tron {
|
|
43
43
|
.contract()
|
44
44
|
.at(this.contractAddress);
|
45
45
|
}
|
46
|
-
if (transaction.
|
46
|
+
if (transaction.subs.length < 0) {
|
47
47
|
throw new Error("Incomplete transaction.");
|
48
48
|
}
|
49
49
|
const result = await Promise.all(
|
50
|
-
transaction.
|
50
|
+
transaction.subs.map(async (item) => {
|
51
51
|
const from = item.from;
|
52
52
|
const parameter = [
|
53
53
|
{ type: "address", value: item.to },
|
@@ -82,7 +82,7 @@ export class TrxTron extends Tron {
|
|
82
82
|
signebleTransaction: SignebleTransaction
|
83
83
|
): Promise<string> {
|
84
84
|
const result = await Promise.all(
|
85
|
-
signebleTransaction.
|
85
|
+
signebleTransaction.subs.map(async (item) => {
|
86
86
|
const transaction = await this.tronWeb.transactionBuilder.sendTrx(
|
87
87
|
item.to,
|
88
88
|
parseInt(item.amount),
|
package/src/poolstream.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Balance } from "./balance";
|
2
|
-
import { Network } from "./network";
|
3
2
|
import { getCoinNetworkModule } from "./currency-network-module";
|
4
3
|
import { SignebleTransaction, SubmittedTransaction } from "./transaction";
|
5
4
|
import { WalletAddress } from "./walletaddress";
|
@@ -20,15 +19,14 @@ export interface TransactionFilter {
|
|
20
19
|
export class PoolStream {
|
21
20
|
constructor(private url: string, private options: PoolStreamOptions = {}) {}
|
22
21
|
|
23
|
-
public async transaction(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
): Promise<SubmittedTransaction> {
|
22
|
+
public async transaction(params: {
|
23
|
+
network: string;
|
24
|
+
txid: string;
|
25
|
+
}): Promise<SubmittedTransaction> {
|
28
26
|
return await axios({
|
29
27
|
method: "get",
|
30
28
|
headers: { ...this.apiKeyHeader() },
|
31
|
-
url: `${this.url}/auth/rest/v1/${
|
29
|
+
url: `${this.url}/auth/rest/v1/${params.network}/transaction/${params.txid}`,
|
32
30
|
responseType: "json",
|
33
31
|
});
|
34
32
|
}
|
@@ -45,7 +43,6 @@ export class PoolStream {
|
|
45
43
|
public async transactions(params: {
|
46
44
|
network: string;
|
47
45
|
filter?: TransactionFilter;
|
48
|
-
contractAddress?: string;
|
49
46
|
}): Promise<Array<SubmittedTransaction>> {
|
50
47
|
const query = Object.entries(params.filter ? params.filter : {})
|
51
48
|
.filter(([_, value]) => value !== undefined)
|
@@ -54,9 +51,7 @@ export class PoolStream {
|
|
54
51
|
return await axios({
|
55
52
|
method: "get",
|
56
53
|
headers: { ...this.apiKeyHeader() },
|
57
|
-
url: `${this.url}/auth/rest/v1/${params.network}
|
58
|
-
params.contractAddress ? `/${params.contractAddress}` : ""
|
59
|
-
}/transactions?${query}`,
|
54
|
+
url: `${this.url}/auth/rest/v1/${params.network}/transactions?${query}`,
|
60
55
|
responseType: "json",
|
61
56
|
});
|
62
57
|
}
|
@@ -64,8 +59,7 @@ export class PoolStream {
|
|
64
59
|
public async balances(params: {
|
65
60
|
network: string;
|
66
61
|
addresses: string | Array<string>;
|
67
|
-
|
68
|
-
}): Promise<Balance> {
|
62
|
+
}): Promise<Array<Balance>> {
|
69
63
|
let query: string = "?";
|
70
64
|
|
71
65
|
if (typeof params.addresses === "string") {
|
@@ -78,17 +72,15 @@ export class PoolStream {
|
|
78
72
|
return await axios({
|
79
73
|
method: "get",
|
80
74
|
headers: { ...this.apiKeyHeader() },
|
81
|
-
url: `${this.url}/auth/rest/v1/${params.network}${
|
82
|
-
params.contractAddress ? `/${params.contractAddress}` : ""
|
83
|
-
}/balances${query}`,
|
75
|
+
url: `${this.url}/auth/rest/v1/${params.network}/balances${query}`,
|
84
76
|
responseType: "json",
|
85
77
|
});
|
86
78
|
}
|
87
79
|
|
88
|
-
public async networks(): Promise<Array<
|
80
|
+
public async networks(): Promise<Array<string>> {
|
89
81
|
return await axios({
|
90
82
|
method: "get",
|
91
|
-
url: `${this.url}/networks`,
|
83
|
+
url: `${this.url}/rest/v1/networks`,
|
92
84
|
responseType: "json",
|
93
85
|
});
|
94
86
|
}
|
@@ -96,14 +88,11 @@ export class PoolStream {
|
|
96
88
|
public async submitTransaction(params: {
|
97
89
|
network: string;
|
98
90
|
signedTransaction: string;
|
99
|
-
contractAddress?: string;
|
100
91
|
}): Promise<Array<string>> {
|
101
92
|
return await axios({
|
102
93
|
method: "post",
|
103
94
|
headers: { ...this.apiKeyHeader() },
|
104
|
-
url: `${this.url}/auth/rest/v1/${params.network}
|
105
|
-
params.contractAddress ? `/${params.contractAddress}` : ""
|
106
|
-
}/submitSignedTransaction`,
|
95
|
+
url: `${this.url}/auth/rest/v1/${params.network}/submitSignedTransaction`,
|
107
96
|
responseType: "json",
|
108
97
|
data: { signedTransaction: params.signedTransaction },
|
109
98
|
});
|
@@ -117,12 +106,11 @@ export class PoolStream {
|
|
117
106
|
const signedTransaction = await getCoinNetworkModule(
|
118
107
|
params.network,
|
119
108
|
false,
|
120
|
-
params.contractAddress
|
109
|
+
!!params.contractAddress
|
121
110
|
).signTransaction(params.transaction);
|
122
111
|
return await this.submitTransaction({
|
123
112
|
network: params.network,
|
124
113
|
signedTransaction,
|
125
|
-
contractAddress: params.contractAddress,
|
126
114
|
});
|
127
115
|
}
|
128
116
|
|
@@ -134,7 +122,7 @@ export class PoolStream {
|
|
134
122
|
return await getCoinNetworkModule(
|
135
123
|
params.network,
|
136
124
|
false,
|
137
|
-
params.contractAddress
|
125
|
+
!!params.contractAddress
|
138
126
|
).signTransaction(params.transaction);
|
139
127
|
}
|
140
128
|
|
package/src/transaction.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
export interface Transaction {
|
2
|
-
|
2
|
+
subs: Array<TransactionItem>;
|
3
3
|
fee?: number;
|
4
4
|
extra?: any;
|
5
5
|
}
|
6
6
|
|
7
7
|
export interface SignebleTransaction extends Transaction {
|
8
|
-
|
8
|
+
subs: Array<TransactionItem & { secret: string }>;
|
9
9
|
}
|
10
10
|
|
11
11
|
export interface TransactionItem {
|
package/tsconfig.json
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
|
-
"outDir": "
|
4
|
-
"rootDir": "./src",
|
3
|
+
"outDir": "dist",
|
5
4
|
"strict": true,
|
5
|
+
"allowJs": true,
|
6
|
+
"declaration": true,
|
6
7
|
"noImplicitOverride": true,
|
7
8
|
"noPropertyAccessFromIndexSignature": true,
|
9
|
+
"emitDeclarationOnly": false,
|
8
10
|
"noImplicitReturns": true,
|
9
11
|
"noFallthroughCasesInSwitch": false,
|
10
12
|
"skipLibCheck": true,
|
11
13
|
"esModuleInterop": true,
|
12
14
|
"sourceMap": true,
|
13
|
-
"declaration": false,
|
14
15
|
"experimentalDecorators": true,
|
15
16
|
"importHelpers": true,
|
16
17
|
"useDefineForClassFields": false,
|
@@ -19,6 +20,6 @@
|
|
19
20
|
"module": "ES2022",
|
20
21
|
"target": "ES2022"
|
21
22
|
},
|
22
|
-
"include": ["src
|
23
|
+
"include": ["src"],
|
23
24
|
"exclude": ["node_modules", "**/__tests__/*"]
|
24
25
|
}
|