@poolstream/client 1.0.1
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/.vscode/launch.json +14 -0
- package/LICENSE +121 -0
- package/README.md +157 -0
- package/babel.config.js +6 -0
- package/dist/balance.js +2 -0
- package/dist/balance.js.map +1 -0
- package/dist/currency-network-module.js +23 -0
- package/dist/currency-network-module.js.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/info.js +2 -0
- package/dist/info.js.map +1 -0
- package/dist/network/ripple/ripple.js +50 -0
- package/dist/network/ripple/ripple.js.map +1 -0
- package/dist/network/solana/solana.js +42 -0
- package/dist/network/solana/solana.js.map +1 -0
- package/dist/network/stellar/stellar.js +102 -0
- package/dist/network/stellar/stellar.js.map +1 -0
- package/dist/network/tron/tron.js +63 -0
- package/dist/network/tron/tron.js.map +1 -0
- package/dist/network.js +2 -0
- package/dist/network.js.map +1 -0
- package/dist/poolstream.js +91 -0
- package/dist/poolstream.js.map +1 -0
- package/dist/transaction.js +2 -0
- package/dist/transaction.js.map +1 -0
- package/dist/walletaddress.js +2 -0
- package/dist/walletaddress.js.map +1 -0
- package/logo_up.png +0 -0
- package/package.json +54 -0
- package/src/balance.ts +6 -0
- package/src/currency-network-module.ts +39 -0
- package/src/index.ts +13 -0
- package/src/info.ts +5 -0
- package/src/network/ripple/ripple.ts +66 -0
- package/src/network/solana/solana.ts +73 -0
- package/src/network/stellar/stellar.ts +149 -0
- package/src/network/tron/tron.ts +96 -0
- package/src/network.ts +4 -0
- package/src/poolstream.ts +153 -0
- package/src/transaction.ts +23 -0
- package/src/walletaddress.ts +7 -0
- package/test/network/ripple/ripple.test.ts +31 -0
- package/test/network/solana/solana.test.ts +32 -0
- package/test/network/stellar/stellar.test.ts +56 -0
- package/test/network/tron/tron.test.ts +53 -0
- package/tests.js +13 -0
- package/tsconfig.json +24 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"version": "0.2.0",
|
3
|
+
"configurations": [
|
4
|
+
{
|
5
|
+
"type": "node",
|
6
|
+
"name": "vscode-jest-tests.v2.poolstream",
|
7
|
+
"request": "launch",
|
8
|
+
"runtimeExecutable": "npm",
|
9
|
+
"runtimeArgs": ["test"],
|
10
|
+
"console": "integratedTerminal",
|
11
|
+
"internalConsoleOptions": "neverOpen"
|
12
|
+
}
|
13
|
+
]
|
14
|
+
}
|
package/LICENSE
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
Creative Commons Legal Code
|
2
|
+
|
3
|
+
CC0 1.0 Universal
|
4
|
+
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
12
|
+
HEREUNDER.
|
13
|
+
|
14
|
+
Statement of Purpose
|
15
|
+
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
19
|
+
authorship and/or a database (each, a "Work").
|
20
|
+
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
28
|
+
culture and the further production of creative, cultural and scientific
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
30
|
+
part through the use and efforts of others.
|
31
|
+
|
32
|
+
For these and/or other purposes and motivations, and without any
|
33
|
+
expectation of additional consideration or compensation, the person
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
39
|
+
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
43
|
+
limited to, the following:
|
44
|
+
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
46
|
+
communicate, and translate a Work;
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
49
|
+
likeness depicted in a Work;
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
53
|
+
in a Work;
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
56
|
+
protection of databases, and under any national implementation
|
57
|
+
thereof, including any amended or successor version of such
|
58
|
+
directive); and
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
60
|
+
world based on applicable law or treaty, and any national
|
61
|
+
implementations thereof.
|
62
|
+
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
72
|
+
including without limitation commercial, advertising or promotional
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
79
|
+
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
100
|
+
express Statement of Purpose.
|
101
|
+
|
102
|
+
4. Limitations and Disclaimers.
|
103
|
+
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
112
|
+
the greatest extent permissible under applicable law.
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
114
|
+
that may apply to the Work or any use thereof, including without
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
117
|
+
consents, permissions or other rights required for any use of the
|
118
|
+
Work.
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
120
|
+
party to this document and has no duty or obligation with respect to
|
121
|
+
this CC0 or use of the Work.
|
package/README.md
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
<h1 align="center">
|
2
|
+
<a href="https://poolstream.io">
|
3
|
+
<img align="center" src="https://raw.githubusercontent.com/lmfacchini/poolstream/refs/heads/master/logo_up.png"/>
|
4
|
+
</a>
|
5
|
+
</h1>
|
6
|
+
|
7
|
+
## What is PoolStream?
|
8
|
+
|
9
|
+
[PoolStream](https://poolstream.io) PoolStream unifies access to various types of cryptocurrencies and their networks through a single API. This access is designed with a straightforward structure, excluding the complexity of smart contracts. Its functionality is limited to controlling fund transfers between wallets..
|
10
|
+
|
11
|
+
## HomePage
|
12
|
+
|
13
|
+
**[poolstream.io](https://poolstream.io)**
|
14
|
+
|
15
|
+
## Compatibility
|
16
|
+
|
17
|
+
- Version built for Node.js v20.18.0 and above
|
18
|
+
|
19
|
+
You can access either version specifically from the dist folder.
|
20
|
+
|
21
|
+
PoolStream is also compatible with frontend frameworks such as:
|
22
|
+
a
|
23
|
+
|
24
|
+
- Angular
|
25
|
+
- React
|
26
|
+
- Vue.
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
### Node.js
|
31
|
+
|
32
|
+
```bash
|
33
|
+
npm install @poolstream/client
|
34
|
+
```
|
35
|
+
|
36
|
+
or
|
37
|
+
|
38
|
+
```bash
|
39
|
+
yarn add @poolstream/client
|
40
|
+
```
|
41
|
+
|
42
|
+
## Production URL
|
43
|
+
|
44
|
+
To use it use the following endpoint:
|
45
|
+
|
46
|
+
```
|
47
|
+
https://api.poolstream.io
|
48
|
+
```
|
49
|
+
|
50
|
+
## API_KEY
|
51
|
+
|
52
|
+
Access: **[dashboard.poolstream.io](https://dashboard.poolstream.io)**
|
53
|
+
|
54
|
+
## Creating an Instance
|
55
|
+
|
56
|
+
First of all, in your typescript file, define PoolStream:
|
57
|
+
|
58
|
+
```typescript
|
59
|
+
import {
|
60
|
+
PoolStream,
|
61
|
+
Transaction,
|
62
|
+
Currency,
|
63
|
+
WalletAddress,
|
64
|
+
Balance,
|
65
|
+
SignebleTransaction,
|
66
|
+
SignedTransaction,
|
67
|
+
} from "poolstream";
|
68
|
+
```
|
69
|
+
|
70
|
+
When you instantiate PoolStream you can define
|
71
|
+
|
72
|
+
- First Param. Ex.: "https://api.poolstream.io"
|
73
|
+
|
74
|
+
you can also set a
|
75
|
+
|
76
|
+
- apiKey: Some features need this parameter.
|
77
|
+
|
78
|
+
```js
|
79
|
+
const poolStream = new PoolStream({
|
80
|
+
"https://api.poolstream.io",
|
81
|
+
{ apiKey: "your api key" },
|
82
|
+
});
|
83
|
+
```
|
84
|
+
|
85
|
+
Find a transaction. This method returns a list of transactions, as some cryptocurrencies encompass multiple fund transfers in one.
|
86
|
+
|
87
|
+
```js
|
88
|
+
const transaction = poolStream.transaction(
|
89
|
+
"usdt",
|
90
|
+
"tron",
|
91
|
+
"26cfbd7d5d7b68537773e8e9889469fd18749816a10ff25e33f25393553bcdb6"
|
92
|
+
);
|
93
|
+
```
|
94
|
+
|
95
|
+
Find many transaction. It is not mandatory to pass the filter, but if it is not passed, the method will return the latest transactions. The maximum number of transactions returned is defined in the site documentation.
|
96
|
+
|
97
|
+
- start [ timestamp unix ]: The earliest timestamp a transaction can have to be included in search results.
|
98
|
+
- end [ timestamp unix ]: The newest timestamp a transaction can have to be included in search results.
|
99
|
+
- from: Transaction origin address.
|
100
|
+
- to: Transaction destination address.
|
101
|
+
- limit: Limit of results. If it is zero or less than zero, then it follows the default address defined in the site's documentation.
|
102
|
+
|
103
|
+
```ts
|
104
|
+
const filter = {
|
105
|
+
start: 1729464035,
|
106
|
+
end: 1730328030,
|
107
|
+
from: "TV2SzAWinU4p7XiTd5UetwWHqRPaa1wT3z",
|
108
|
+
to: "T9yutTZ2z6yGA7hHuHupndQwmaSrAizE7R",
|
109
|
+
limit: 10,
|
110
|
+
};
|
111
|
+
const transactions = poolStream.transactions("usdt", "tron", filter);
|
112
|
+
```
|
113
|
+
|
114
|
+
Check the balance of one or more wallets.
|
115
|
+
|
116
|
+
```ts
|
117
|
+
const balance = poolStream.balance(
|
118
|
+
"usdt",
|
119
|
+
"tron",
|
120
|
+
"TV2SzAWinU4p7XiTd5UetwWHqRPaa1wT3z"
|
121
|
+
);
|
122
|
+
```
|
123
|
+
|
124
|
+
or
|
125
|
+
|
126
|
+
```ts
|
127
|
+
const balance = poolStream.balance("usdt", "tron", [
|
128
|
+
"TV2SzAWinU4p7XiTd5UetwWHqRPaa1wT3z",
|
129
|
+
"T9yutTZ2z6yGA7hHuHupndQwmaSrAizE7R",
|
130
|
+
]);
|
131
|
+
```
|
132
|
+
|
133
|
+
Generate Wallet Address.
|
134
|
+
|
135
|
+
```ts
|
136
|
+
const balance = poolStream.generateWalletAddress("usdt", "tron");
|
137
|
+
```
|
138
|
+
|
139
|
+
Signs and submits the transaction to the network.
|
140
|
+
|
141
|
+
```ts
|
142
|
+
const txid = poolStream.signedAndSubmitTransaction("usdt", "tron", {
|
143
|
+
from: "TV2SzAWinU4p7XiTd5UetwWHqRPaa1wT3z";
|
144
|
+
to: "T9yutTZ2z6yGA7hHuHupndQwmaSrAizE7R";
|
145
|
+
amount: 12000000, //int64
|
146
|
+
fee: 350000 // int64
|
147
|
+
privateKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
148
|
+
});
|
149
|
+
```
|
150
|
+
|
151
|
+
## Licence
|
152
|
+
|
153
|
+
PoolStream is distributed under a Creative Commons Legal Code licence.
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
```
|
package/babel.config.js
ADDED
package/dist/balance.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../src/balance.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { Ripple } from "./network/ripple/ripple";
|
2
|
+
import { Solana } from "./network/solana/solana";
|
3
|
+
import { Stellar } from "./network/stellar/stellar";
|
4
|
+
import { Tron } from "./network/tron/tron";
|
5
|
+
export function getCoinNetworkModule(network, test = false, contractAddress) {
|
6
|
+
network = network.toLowerCase();
|
7
|
+
const nw = networks[network];
|
8
|
+
if (nw) {
|
9
|
+
const instanceCurrencyModule = nw.currencies(contractAddress);
|
10
|
+
if (instanceCurrencyModule) {
|
11
|
+
return instanceCurrencyModule(test);
|
12
|
+
}
|
13
|
+
throw new Error(`Contract Address [${contractAddress}]. Network [${network}] not available.`);
|
14
|
+
}
|
15
|
+
throw new Error(`Network [${network}] not available.`);
|
16
|
+
}
|
17
|
+
export const networks = {
|
18
|
+
tron: Tron,
|
19
|
+
stellar: Stellar,
|
20
|
+
solana: Solana,
|
21
|
+
ripple: Ripple,
|
22
|
+
};
|
23
|
+
//# sourceMappingURL=currency-network-module.js.map
|
@@ -0,0 +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,eAAwB;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,UAAU,CAAC,eAAe,CAAC,CAAC;QAC9D,IAAI,sBAAsB,EAAE,CAAC;YAC3B,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,qBAAqB,eAAe,eAAe,OAAO,kBAAkB,CAC7E,CAAC;IACJ,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.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAC;AAI7D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/info.js
ADDED
package/dist/info.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { Wallet } from "xrpl";
|
2
|
+
export class Ripple {
|
3
|
+
constructor() {
|
4
|
+
this.network = "ripple";
|
5
|
+
}
|
6
|
+
async generateWalletAddress() {
|
7
|
+
const wallet = Wallet.generate();
|
8
|
+
return {
|
9
|
+
address: wallet.classicAddress,
|
10
|
+
secret: wallet.seed ? wallet.seed : wallet.privateKey,
|
11
|
+
currency: "xrp",
|
12
|
+
network: this.network,
|
13
|
+
raw: wallet,
|
14
|
+
};
|
15
|
+
}
|
16
|
+
}
|
17
|
+
// export class GenericRipple extends Ripple {
|
18
|
+
// constructor(protected readonly assetAddress: string, currency: string) {
|
19
|
+
// super(currency);
|
20
|
+
// }
|
21
|
+
// async signTransaction(transaction: SignebleTransaction): Promise<string> {
|
22
|
+
// throw new Error("Method not implemented.");
|
23
|
+
// }
|
24
|
+
// }
|
25
|
+
export class XrpRipple extends Ripple {
|
26
|
+
constructor() {
|
27
|
+
super();
|
28
|
+
}
|
29
|
+
async signTransaction(signebleTransaction) {
|
30
|
+
const signTransactions = Promise.all(signebleTransaction.items.map(async (item) => {
|
31
|
+
const seedWallet = Wallet.fromSeed(item.secret);
|
32
|
+
const Memos = item.extra ? item.extra.memos : undefined;
|
33
|
+
const Fee = signebleTransaction.fee
|
34
|
+
? signebleTransaction.fee.toString()
|
35
|
+
: undefined;
|
36
|
+
const tx = {
|
37
|
+
TransactionType: "Payment",
|
38
|
+
Account: item.from,
|
39
|
+
Destination: item.to,
|
40
|
+
Amount: item.amount,
|
41
|
+
Memos,
|
42
|
+
Fee,
|
43
|
+
};
|
44
|
+
const signedTx = seedWallet.sign(tx);
|
45
|
+
return btoa(JSON.stringify(signedTx.tx_blob));
|
46
|
+
}));
|
47
|
+
return btoa(JSON.stringify(signTransactions));
|
48
|
+
}
|
49
|
+
}
|
50
|
+
//# sourceMappingURL=ripple.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ripple.js","source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B,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,42 @@
|
|
1
|
+
import { clusterApiUrl, Connection, Keypair, PublicKey, SystemProgram, Transaction, } from "@solana/web3.js";
|
2
|
+
export class Solana {
|
3
|
+
constructor(test = false) {
|
4
|
+
this.network = "solana";
|
5
|
+
this.connection = new Connection(clusterApiUrl(test ? "devnet" : "mainnet-beta"));
|
6
|
+
}
|
7
|
+
async generateWalletAddress() {
|
8
|
+
const wallet = Keypair.generate();
|
9
|
+
return {
|
10
|
+
address: wallet.publicKey.toBase58(),
|
11
|
+
secret: Buffer.from(wallet.secretKey).toString("hex"),
|
12
|
+
currency: "sol",
|
13
|
+
network: this.network,
|
14
|
+
raw: wallet,
|
15
|
+
};
|
16
|
+
}
|
17
|
+
}
|
18
|
+
export class SolSolana extends Solana {
|
19
|
+
constructor(test = false) {
|
20
|
+
super(test);
|
21
|
+
}
|
22
|
+
async signTransaction(signebleTransaction) {
|
23
|
+
const signTransactions = Promise.all(signebleTransaction.items.map(async (item) => {
|
24
|
+
const senderSecretKey = Uint8Array.from(Buffer.from(item.secret, "hex"));
|
25
|
+
const sender = Keypair.fromSecretKey(senderSecretKey);
|
26
|
+
const receiver = new PublicKey(item.to);
|
27
|
+
const { blockhash } = await this.connection.getLatestBlockhash();
|
28
|
+
const transaction = new Transaction().add(SystemProgram.transfer({
|
29
|
+
fromPubkey: new PublicKey(item.from),
|
30
|
+
toPubkey: receiver,
|
31
|
+
lamports: parseInt(item.amount),
|
32
|
+
}));
|
33
|
+
transaction.recentBlockhash = blockhash;
|
34
|
+
transaction.feePayer = sender.publicKey;
|
35
|
+
transaction.sign(sender);
|
36
|
+
return transaction.serialize().toString("base64");
|
37
|
+
}));
|
38
|
+
return btoa(JSON.stringify(signTransactions));
|
39
|
+
}
|
40
|
+
}
|
41
|
+
const modules = { sol: (test = false) => new SolSolana() };
|
42
|
+
//# sourceMappingURL=solana.js.map
|
@@ -0,0 +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/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AAE,EAAE,CAAC"}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import { Horizon, Keypair, Asset, BASE_FEE, Memo, Networks, Operation, TransactionBuilder, } from "@stellar/stellar-sdk";
|
2
|
+
import * as crypto from "crypto";
|
3
|
+
export class Stellar {
|
4
|
+
constructor(test) {
|
5
|
+
this.network = "stellar";
|
6
|
+
this.server = new Horizon.Server(test
|
7
|
+
? "https://horizon-testnet.stellar.org"
|
8
|
+
: "https://horizon-futurenet.stellar.org");
|
9
|
+
}
|
10
|
+
async generateWalletAddress() {
|
11
|
+
const randomBytes = crypto.randomBytes(32);
|
12
|
+
const result = Keypair.fromRawEd25519Seed(Buffer.from(randomBytes));
|
13
|
+
return {
|
14
|
+
address: result.publicKey(),
|
15
|
+
secret: result.secret(),
|
16
|
+
currency: "xlm",
|
17
|
+
network: "stellar",
|
18
|
+
raw: result,
|
19
|
+
};
|
20
|
+
}
|
21
|
+
}
|
22
|
+
export class GenericStellar extends Stellar {
|
23
|
+
constructor(assetAddress, test = false) {
|
24
|
+
super(test);
|
25
|
+
this.assetAddress = assetAddress;
|
26
|
+
this.test = {
|
27
|
+
signebleTransaction: {
|
28
|
+
fee: 350000,
|
29
|
+
items: [
|
30
|
+
{
|
31
|
+
from: "TKTcGX3tVBk8Y5p5uhFTqcEXT4Tg7C9iTD",
|
32
|
+
privateKey: "4d6e85f83e2e0e7fd78413e11662323f8bf8daa05089f520ec8dc2bb98996863",
|
33
|
+
to: "TRrEckDtWQWGpZHTT477VpAxaq1mFTbas5",
|
34
|
+
amount: "230000000000000000",
|
35
|
+
},
|
36
|
+
],
|
37
|
+
},
|
38
|
+
};
|
39
|
+
}
|
40
|
+
async signTransaction(transaction) {
|
41
|
+
if (transaction.items.length < 0) {
|
42
|
+
throw new Error("Incomplete transaction.");
|
43
|
+
}
|
44
|
+
const result = await Promise.all(transaction.items.map(async (item) => {
|
45
|
+
const senderAccount = await this.server.loadAccount(item.from);
|
46
|
+
let transactionBuilder = new TransactionBuilder(senderAccount, {
|
47
|
+
fee: BASE_FEE,
|
48
|
+
networkPassphrase: Networks.FUTURENET,
|
49
|
+
}).addOperation(Operation.payment({
|
50
|
+
destination: item.to,
|
51
|
+
asset: Asset.native(),
|
52
|
+
amount: item.amount,
|
53
|
+
}));
|
54
|
+
if (item.extra) {
|
55
|
+
if (item.extra.memo) {
|
56
|
+
transactionBuilder = transactionBuilder.addMemo(Memo.text(item.extra.memo));
|
57
|
+
}
|
58
|
+
if (item.extra.timeout) {
|
59
|
+
transactionBuilder = transactionBuilder.setTimeout(item.extra.timeout);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
const senderKeypair = Keypair.fromSecret(item.secret);
|
63
|
+
const signedTransaction = transactionBuilder
|
64
|
+
.build()
|
65
|
+
.sign(senderKeypair);
|
66
|
+
return btoa(JSON.stringify(signedTransaction));
|
67
|
+
}));
|
68
|
+
return btoa(JSON.stringify(result));
|
69
|
+
}
|
70
|
+
}
|
71
|
+
export class XlmStellar extends Stellar {
|
72
|
+
constructor(test = false) {
|
73
|
+
super(test);
|
74
|
+
}
|
75
|
+
async signTransaction(signebleTransaction) {
|
76
|
+
const signTransactions = Promise.all(signebleTransaction.items.map(async (item) => {
|
77
|
+
const account = await this.server.loadAccount(item.from);
|
78
|
+
let transactionBuilder = new TransactionBuilder(account, {
|
79
|
+
fee: BASE_FEE,
|
80
|
+
networkPassphrase: Networks.FUTURENET,
|
81
|
+
}).addOperation(Operation.payment({
|
82
|
+
destination: item.to,
|
83
|
+
asset: Asset.native(),
|
84
|
+
amount: item.amount,
|
85
|
+
}));
|
86
|
+
if (item.extra) {
|
87
|
+
if (item.extra.memo) {
|
88
|
+
transactionBuilder = transactionBuilder.addMemo(Memo.text(item.extra.memo));
|
89
|
+
}
|
90
|
+
if (item.extra.timeout) {
|
91
|
+
transactionBuilder = transactionBuilder.setTimeout(item.extra.timeout);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
const signedTransaction = transactionBuilder
|
95
|
+
.build()
|
96
|
+
.sign(Keypair.fromSecret(item.secret));
|
97
|
+
return btoa(JSON.stringify(signedTransaction));
|
98
|
+
}));
|
99
|
+
return btoa(JSON.stringify(signTransactions));
|
100
|
+
}
|
101
|
+
}
|
102
|
+
//# sourceMappingURL=stellar.js.map
|
@@ -0,0 +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,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,OAAgB,OAAO;IAG3B,YAAY,IAAa;QADhB,YAAO,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAC9B,IAAI;YACF,CAAC,CAAC,qCAAqC;YACvC,CAAC,CAAC,uCAAuC,CAC5C,CAAC;IACJ,CAAC;IAID,KAAK,CAAC,qBAAqB;QACzB,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAEpE,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;YACvB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,SAAS;YAClB,GAAG,EAAE,MAAM;SACZ,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,OAAO;IACzC,YAA+B,YAAoB,EAAE,OAAgB,KAAK;QACxE,KAAK,CAAC,IAAI,CAAC,CAAC;QADiB,iBAAY,GAAZ,YAAY,CAAQ;QAGnD,SAAI,GAAG;YACL,mBAAmB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kB,GAAG,kBAAkB,CAAC,OAAO,CAC7C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAC3B,CAAC;gBACJ,CAAC;gBACD,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;oBACvB,kBAAkB,GAAG,kBAAkB,CAAC,UAAU,CAChD,IAAI,CAAC,KAAK,CAAC,OAAO,CACnB,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,MAAM,iBAAiB,GAAG,kBAAkB;iBACzC,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,63 @@
|
|
1
|
+
import { TronWeb, utils } from "tronweb";
|
2
|
+
export class Tron {
|
3
|
+
constructor(test) {
|
4
|
+
this.network = "tron";
|
5
|
+
this.tronWeb = new TronWeb({
|
6
|
+
fullHost: test
|
7
|
+
? "https://api.shasta.trongrid.io"
|
8
|
+
: "https://api.trongrid.io",
|
9
|
+
});
|
10
|
+
}
|
11
|
+
async generateWalletAddress() {
|
12
|
+
const result = utils.accounts.generateAccount();
|
13
|
+
return {
|
14
|
+
address: result.address.base58,
|
15
|
+
secret: result.privateKey,
|
16
|
+
currency: "trx",
|
17
|
+
network: "tron",
|
18
|
+
raw: result,
|
19
|
+
};
|
20
|
+
}
|
21
|
+
}
|
22
|
+
const functionSelector = "transfer(address, uint256)";
|
23
|
+
export class GenericTron extends Tron {
|
24
|
+
constructor(contractAddress, test = false) {
|
25
|
+
super(test);
|
26
|
+
this.contractAddress = contractAddress;
|
27
|
+
this.usdtContract = null;
|
28
|
+
}
|
29
|
+
async signTransaction(transaction) {
|
30
|
+
if (this.usdtContract === null) {
|
31
|
+
this.usdtContract = await this.tronWeb
|
32
|
+
.contract()
|
33
|
+
.at(this.contractAddress);
|
34
|
+
}
|
35
|
+
if (transaction.items.length < 0) {
|
36
|
+
throw new Error("Incomplete transaction.");
|
37
|
+
}
|
38
|
+
const result = await Promise.all(transaction.items.map(async (item) => {
|
39
|
+
const from = item.from;
|
40
|
+
const parameter = [
|
41
|
+
{ type: "address", value: item.to },
|
42
|
+
{ type: "uint256", value: item.amount },
|
43
|
+
];
|
44
|
+
const usdttransaction = await this.tronWeb.transactionBuilder.triggerSmartContract(this.contractAddress, functionSelector, { feeLimit: transaction.fee }, parameter, from);
|
45
|
+
const signedTransaction = utils.crypto.signTransaction(item.secret, usdttransaction.transaction);
|
46
|
+
return btoa(JSON.stringify(signedTransaction));
|
47
|
+
}));
|
48
|
+
return btoa(JSON.stringify(result));
|
49
|
+
}
|
50
|
+
}
|
51
|
+
export class TrxTron extends Tron {
|
52
|
+
constructor(test = false) {
|
53
|
+
super(test);
|
54
|
+
}
|
55
|
+
async signTransaction(signebleTransaction) {
|
56
|
+
const result = await Promise.all(signebleTransaction.items.map(async (item) => {
|
57
|
+
const transaction = await this.tronWeb.transactionBuilder.sendTrx(item.to, parseInt(item.amount), item.from);
|
58
|
+
return this.tronWeb.trx.sign(transaction, item.secret);
|
59
|
+
}));
|
60
|
+
return btoa(JSON.stringify(result));
|
61
|
+
}
|
62
|
+
}
|
63
|
+
//# sourceMappingURL=tron.js.map
|
@@ -0,0 +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,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