mainnet-js 1.1.34 → 2.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/dist/index.html +1 -1
- package/dist/{mainnet-1.1.34.js → mainnet-2.0.0.js} +25 -337
- package/dist/module/db/SqlProvider.d.ts +2 -2
- package/dist/module/db/SqlProvider.d.ts.map +1 -1
- package/dist/module/db/SqlProvider.js +6 -24
- package/dist/module/db/SqlProvider.js.map +1 -1
- package/dist/module/index.d.ts +0 -3
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +3 -6
- package/dist/module/index.js.map +1 -1
- package/dist/module/transaction/Wif.d.ts +4 -8
- package/dist/module/transaction/Wif.d.ts.map +1 -1
- package/dist/module/transaction/Wif.js +6 -10
- package/dist/module/transaction/Wif.js.map +1 -1
- package/dist/module/util/deriveCashaddr.d.ts +1 -0
- package/dist/module/util/deriveCashaddr.d.ts.map +1 -1
- package/dist/module/util/deriveCashaddr.js +8 -1
- package/dist/module/util/deriveCashaddr.js.map +1 -1
- package/dist/module/wallet/Base.d.ts +1 -1
- package/dist/module/wallet/Base.js +1 -1
- package/dist/module/wallet/Util.d.ts +2 -2
- package/dist/module/wallet/Util.js +2 -2
- package/dist/module/wallet/Wif.d.ts +0 -28
- package/dist/module/wallet/Wif.d.ts.map +1 -1
- package/dist/module/wallet/Wif.js +2 -109
- package/dist/module/wallet/Wif.js.map +1 -1
- package/dist/module/wallet/createWallet.d.ts +0 -12
- package/dist/module/wallet/createWallet.d.ts.map +1 -1
- package/dist/module/wallet/createWallet.js +0 -43
- package/dist/module/wallet/createWallet.js.map +1 -1
- package/dist/module/wallet/interface.d.ts +0 -2
- package/dist/module/wallet/interface.d.ts.map +1 -1
- package/dist/module/webhook/Webhook.d.ts +1 -6
- package/dist/module/webhook/Webhook.d.ts.map +1 -1
- package/dist/module/webhook/Webhook.js +0 -4
- package/dist/module/webhook/Webhook.js.map +1 -1
- package/dist/module/webhook/index.d.ts +0 -1
- package/dist/module/webhook/index.d.ts.map +1 -1
- package/dist/module/webhook/index.js +0 -1
- package/dist/module/webhook/index.js.map +1 -1
- package/dist/module/webhook/interface.d.ts +0 -1
- package/dist/module/webhook/interface.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -10
- package/src/db/SqlProvider.test.ts +2 -18
- package/src/db/SqlProvider.ts +5 -26
- package/src/index.ts +3 -7
- package/src/transaction/Wif.ts +2 -19
- package/src/util/deriveCashaddr.test.ts +8 -0
- package/src/util/deriveCashaddr.ts +9 -0
- package/src/wallet/Base.ts +1 -1
- package/src/wallet/Util.ts +2 -2
- package/src/wallet/Wif.test.ts +0 -23
- package/src/wallet/Wif.ts +2 -148
- package/src/wallet/createWallet.ts +0 -53
- package/src/wallet/interface.ts +0 -2
- package/src/webhook/Webhook.ts +4 -10
- package/src/webhook/index.ts +0 -1
- package/src/webhook/interface.ts +0 -1
- package/webpack.config.cjs +7 -7
- package/dist/module/slp/GsppProvider.d.ts +0 -55
- package/dist/module/slp/GsppProvider.d.ts.map +0 -1
- package/dist/module/slp/GsppProvider.js +0 -204
- package/dist/module/slp/GsppProvider.js.map +0 -1
- package/dist/module/slp/SlpDbProvider.d.ts +0 -52
- package/dist/module/slp/SlpDbProvider.d.ts.map +0 -1
- package/dist/module/slp/SlpDbProvider.js +0 -175
- package/dist/module/slp/SlpDbProvider.js.map +0 -1
- package/dist/module/slp/SlpDbTemplates.d.ts +0 -313
- package/dist/module/slp/SlpDbTemplates.d.ts.map +0 -1
- package/dist/module/slp/SlpDbTemplates.js +0 -375
- package/dist/module/slp/SlpDbTemplates.js.map +0 -1
- package/dist/module/slp/SlpLibAuth.d.ts +0 -210
- package/dist/module/slp/SlpLibAuth.d.ts.map +0 -1
- package/dist/module/slp/SlpLibAuth.js +0 -451
- package/dist/module/slp/SlpLibAuth.js.map +0 -1
- package/dist/module/slp/SlpProvider.d.ts +0 -24
- package/dist/module/slp/SlpProvider.d.ts.map +0 -1
- package/dist/module/slp/SlpProvider.js +0 -29
- package/dist/module/slp/SlpProvider.js.map +0 -1
- package/dist/module/slp/index.d.ts +0 -6
- package/dist/module/slp/index.d.ts.map +0 -1
- package/dist/module/slp/index.js +0 -5
- package/dist/module/slp/index.js.map +0 -1
- package/dist/module/slp/interface.d.ts +0 -114
- package/dist/module/slp/interface.d.ts.map +0 -1
- package/dist/module/slp/interface.js +0 -7
- package/dist/module/slp/interface.js.map +0 -1
- package/dist/module/util/bchaddr.d.ts +0 -2
- package/dist/module/util/bchaddr.d.ts.map +0 -1
- package/dist/module/util/bchaddr.js +0 -16
- package/dist/module/util/bchaddr.js.map +0 -1
- package/dist/module/wallet/Slp.d.ts +0 -431
- package/dist/module/wallet/Slp.d.ts.map +0 -1
- package/dist/module/wallet/Slp.js +0 -770
- package/dist/module/wallet/Slp.js.map +0 -1
- package/dist/module/webhook/WebhookSlp.d.ts +0 -15
- package/dist/module/webhook/WebhookSlp.d.ts.map +0 -1
- package/dist/module/webhook/WebhookSlp.js +0 -100
- package/dist/module/webhook/WebhookSlp.js.map +0 -1
- package/src/slp/GsppProvider.test.ts +0 -40
- package/src/slp/GsppProvider.ts +0 -329
- package/src/slp/SlpDbProvider.test.ts +0 -27
- package/src/slp/SlpDbProvider.ts +0 -291
- package/src/slp/SlpDbTemplates.ts +0 -400
- package/src/slp/SlpLibAuth.test.ts +0 -162
- package/src/slp/SlpLibAuth.ts +0 -532
- package/src/slp/SlpProvider.ts +0 -100
- package/src/slp/index.ts +0 -6
- package/src/slp/interface.ts +0 -128
- package/src/util/bchaddr.test.ts +0 -27
- package/src/util/bchaddr.ts +0 -27
- package/src/wallet/Slp.test.headless.js +0 -120
- package/src/wallet/Slp.test.ts +0 -1000
- package/src/wallet/Slp.ts +0 -1014
- package/src/webhook/WebhookSlp.test.ts +0 -288
- package/src/webhook/WebhookSlp.ts +0 -123
package/src/slp/SlpProvider.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SlpTokenBalance,
|
|
3
|
-
SlpTokenInfo,
|
|
4
|
-
SlpTxI,
|
|
5
|
-
SlpUtxoI,
|
|
6
|
-
} from "./interface.js";
|
|
7
|
-
import BigNumber from "bignumber.js";
|
|
8
|
-
|
|
9
|
-
export type SlpWatchTransactionCallback = (tx: SlpTxI) => void;
|
|
10
|
-
export type SlpCancelWatchFn = () => Promise<void>;
|
|
11
|
-
export type SlpWatchBalanceCallback = (balance: SlpTokenBalance) => void;
|
|
12
|
-
|
|
13
|
-
export interface SlpProvider {
|
|
14
|
-
// all oupoints, including mint batons
|
|
15
|
-
SlpOutpoints(slpaddr: string): Promise<String[]>;
|
|
16
|
-
|
|
17
|
-
// all utxos, including mint batons
|
|
18
|
-
SlpUtxos(slpaddr: string): Promise<SlpUtxoI[]>;
|
|
19
|
-
|
|
20
|
-
// look up the token information
|
|
21
|
-
SlpTokenInfo(tokenId: string): Promise<SlpTokenInfo | undefined>;
|
|
22
|
-
|
|
23
|
-
// safe-spendable token utxos, without baton
|
|
24
|
-
SlpSpendableUtxos(slpaddr: string, tokenId?: string): Promise<SlpUtxoI[]>;
|
|
25
|
-
|
|
26
|
-
// token mint baton utxos
|
|
27
|
-
SlpBatonUtxos(slpaddr: string, tokenId?: string): Promise<SlpUtxoI[]>;
|
|
28
|
-
|
|
29
|
-
// get all token balances
|
|
30
|
-
SlpAllTokenBalances(slpaddr: string): Promise<SlpTokenBalance[]>;
|
|
31
|
-
|
|
32
|
-
// get specific token balance
|
|
33
|
-
SlpTokenBalance(slpaddr: string, tokenId: string): Promise<SlpTokenBalance>;
|
|
34
|
-
|
|
35
|
-
// get all slp transactions of this address
|
|
36
|
-
SlpAddressTransactionHistory(
|
|
37
|
-
slpaddr: string,
|
|
38
|
-
tokenId?: string
|
|
39
|
-
): Promise<SlpTxI[]>;
|
|
40
|
-
|
|
41
|
-
// waits for next slp transaction to appear in mempool, code execution is halted
|
|
42
|
-
SlpWaitForTransaction(slpaddr: string, tokenId?: string): Promise<SlpTxI>;
|
|
43
|
-
|
|
44
|
-
// waits for a certain slp token balance to be available in this wallet, code execution is halted
|
|
45
|
-
SlpWaitForBalance(
|
|
46
|
-
value: BigNumber.Value,
|
|
47
|
-
slpaddr: string,
|
|
48
|
-
tokenId: string
|
|
49
|
-
): Promise<SlpTokenBalance>;
|
|
50
|
-
|
|
51
|
-
// set's up a callback to be executed each time the token balance of the wallet is changed
|
|
52
|
-
SlpWatchBalance(
|
|
53
|
-
callback: SlpWatchBalanceCallback,
|
|
54
|
-
slpaddr: string,
|
|
55
|
-
tokenId: string
|
|
56
|
-
): SlpCancelWatchFn;
|
|
57
|
-
|
|
58
|
-
// sets up a callback to be executed each time a new transaction associated with this wallet's address is entering the mempool
|
|
59
|
-
SlpWatchTransactions(
|
|
60
|
-
callback: SlpWatchTransactionCallback,
|
|
61
|
-
slpaddr?: string,
|
|
62
|
-
tokenId?: string
|
|
63
|
-
): SlpCancelWatchFn;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function _convertBalanceBigNumbers(
|
|
67
|
-
balances: SlpTokenBalance[]
|
|
68
|
-
): SlpTokenBalance[] {
|
|
69
|
-
balances.forEach((val) => (val.value = new BigNumber(val.value)));
|
|
70
|
-
return balances;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function _convertUtxoBigNumbers(utxos: SlpUtxoI[]): SlpUtxoI[] {
|
|
74
|
-
utxos.forEach((val) => (val.value = new BigNumber(val.value)));
|
|
75
|
-
return utxos;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function _convertSlpTokenInfo(
|
|
79
|
-
tokenInfo: SlpTokenInfo | undefined
|
|
80
|
-
): SlpTokenInfo | undefined {
|
|
81
|
-
if (!tokenInfo) return tokenInfo;
|
|
82
|
-
|
|
83
|
-
for (const key in tokenInfo) {
|
|
84
|
-
if (tokenInfo[key] === null) {
|
|
85
|
-
tokenInfo[key] = "";
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
tokenInfo.initialAmount = new BigNumber(tokenInfo.initialAmount);
|
|
89
|
-
|
|
90
|
-
return tokenInfo;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function _emptyTokenBalance(tokenId: string): SlpTokenBalance {
|
|
94
|
-
return {
|
|
95
|
-
value: new BigNumber(0),
|
|
96
|
-
ticker: "",
|
|
97
|
-
name: "",
|
|
98
|
-
tokenId: tokenId,
|
|
99
|
-
} as SlpTokenBalance;
|
|
100
|
-
}
|
package/src/slp/index.ts
DELETED
package/src/slp/interface.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
|
-
import { UtxoI, TxI } from "../interface.js";
|
|
3
|
-
|
|
4
|
-
export enum SlpTokenType {
|
|
5
|
-
Type1 = 0x01,
|
|
6
|
-
NftParent = 0x81,
|
|
7
|
-
NftChild = 0x41,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface SlpDbResponse {
|
|
11
|
-
t: any[];
|
|
12
|
-
u: any[];
|
|
13
|
-
c: any[];
|
|
14
|
-
g: any[];
|
|
15
|
-
a: any[];
|
|
16
|
-
x: any[];
|
|
17
|
-
s: any[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface SlpDbTx {
|
|
21
|
-
tx: any;
|
|
22
|
-
in: any[];
|
|
23
|
-
out: any[];
|
|
24
|
-
slp: any;
|
|
25
|
-
blk: any;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface GsppTx {
|
|
29
|
-
inputs: string[];
|
|
30
|
-
outputs: string[];
|
|
31
|
-
tokenId: string;
|
|
32
|
-
groupId: string;
|
|
33
|
-
type: SlpTokenType;
|
|
34
|
-
ticker: string;
|
|
35
|
-
decimals: number;
|
|
36
|
-
txType: string;
|
|
37
|
-
txHash: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface SlpTxI extends TxI {
|
|
41
|
-
details: SlpDbTx | GsppTx;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface SlpUtxoI extends UtxoI {
|
|
45
|
-
value: BigNumber;
|
|
46
|
-
decimals: number;
|
|
47
|
-
ticker: string;
|
|
48
|
-
tokenId: string;
|
|
49
|
-
type: SlpTokenType;
|
|
50
|
-
isBaton: boolean;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface SlpFormattedUtxo {
|
|
54
|
-
ticker: string;
|
|
55
|
-
tokenId: string;
|
|
56
|
-
value: string;
|
|
57
|
-
satoshis: number;
|
|
58
|
-
decimals: number;
|
|
59
|
-
txId: string;
|
|
60
|
-
index: number;
|
|
61
|
-
utxoId: string;
|
|
62
|
-
type: SlpTokenType;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface SlpTokenBalance {
|
|
66
|
-
value: BigNumber;
|
|
67
|
-
ticker: string;
|
|
68
|
-
name: string;
|
|
69
|
-
tokenId: string;
|
|
70
|
-
type: SlpTokenType;
|
|
71
|
-
decimals: number;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface SlpSendRequest {
|
|
75
|
-
slpaddr: string;
|
|
76
|
-
value: BigNumber.Value;
|
|
77
|
-
tokenId: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface SlpTokenInfo {
|
|
81
|
-
name: string;
|
|
82
|
-
ticker: string;
|
|
83
|
-
tokenId: string;
|
|
84
|
-
parentTokenId: string;
|
|
85
|
-
initialAmount: BigNumber.Value;
|
|
86
|
-
decimals: number;
|
|
87
|
-
documentUrl?: string;
|
|
88
|
-
documentHash?: string;
|
|
89
|
-
type: SlpTokenType;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface SlpGenesisOptions {
|
|
93
|
-
name: string;
|
|
94
|
-
ticker: string;
|
|
95
|
-
initialAmount: BigNumber.Value;
|
|
96
|
-
decimals: number;
|
|
97
|
-
documentUrl?: string;
|
|
98
|
-
documentHash?: string;
|
|
99
|
-
endBaton?: boolean;
|
|
100
|
-
type?: SlpTokenType;
|
|
101
|
-
tokenReceiverSlpAddr?: string;
|
|
102
|
-
batonReceiverSlpAddr?: string;
|
|
103
|
-
parentTokenId?: string;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface SlpMintOptions {
|
|
107
|
-
value: BigNumber.Value;
|
|
108
|
-
tokenId: string;
|
|
109
|
-
endBaton?: boolean;
|
|
110
|
-
tokenReceiverSlpAddr?: string;
|
|
111
|
-
batonReceiverSlpAddr?: string;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface SlpGenesisResult {
|
|
115
|
-
tokenId: string;
|
|
116
|
-
balance: SlpTokenBalance;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export interface SlpSendResponse {
|
|
120
|
-
txId: string;
|
|
121
|
-
balance: SlpTokenBalance;
|
|
122
|
-
explorerUrl: string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface SlpMintResult {
|
|
126
|
-
txId: string;
|
|
127
|
-
balance: SlpTokenBalance;
|
|
128
|
-
}
|
package/src/util/bchaddr.test.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { toCashAddress, toSlpAddress } from "./bchaddr";
|
|
2
|
-
|
|
3
|
-
test.skip("Should convert between bch and slp addresses", async () => {
|
|
4
|
-
let addr = "bitcoincash:qpttdv3qg2usm4nm7talhxhl05mlhms3ystlwcm8h4";
|
|
5
|
-
let slpAddr = "simpleledger:qpttdv3qg2usm4nm7talhxhl05mlhms3ys8y9rw8ft";
|
|
6
|
-
expect(toCashAddress(addr)).toBe(addr);
|
|
7
|
-
expect(toSlpAddress(addr)).toBe(slpAddr);
|
|
8
|
-
|
|
9
|
-
expect(toCashAddress(slpAddr)).toBe(addr);
|
|
10
|
-
expect(toSlpAddress(addr)).toBe(slpAddr);
|
|
11
|
-
|
|
12
|
-
addr = "bchtest:qpttdv3qg2usm4nm7talhxhl05mlhms3ys0d2lessf";
|
|
13
|
-
slpAddr = "slptest:qpttdv3qg2usm4nm7talhxhl05mlhms3ys5edyr8z5";
|
|
14
|
-
expect(toCashAddress(addr)).toBe(addr);
|
|
15
|
-
expect(toSlpAddress(addr)).toBe(slpAddr);
|
|
16
|
-
|
|
17
|
-
expect(toCashAddress(slpAddr)).toBe(addr);
|
|
18
|
-
expect(toSlpAddress(addr)).toBe(slpAddr);
|
|
19
|
-
|
|
20
|
-
addr = "bchreg:qpttdv3qg2usm4nm7talhxhl05mlhms3ys43u76rn0";
|
|
21
|
-
slpAddr = "slpreg:qpttdv3qg2usm4nm7talhxhl05mlhms3ysg3x0302x";
|
|
22
|
-
expect(toCashAddress(addr)).toBe(addr);
|
|
23
|
-
expect(toSlpAddress(addr)).toBe(slpAddr);
|
|
24
|
-
|
|
25
|
-
expect(toCashAddress(slpAddr)).toBe(addr);
|
|
26
|
-
expect(toSlpAddress(addr)).toBe(slpAddr);
|
|
27
|
-
});
|
package/src/util/bchaddr.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
toCashAddress,
|
|
3
|
-
toSlpAddress,
|
|
4
|
-
isValidAddress,
|
|
5
|
-
isCashAddress,
|
|
6
|
-
isSlpAddress,
|
|
7
|
-
} from "bchaddrjs-slp";
|
|
8
|
-
|
|
9
|
-
// import bchaddr from "bchaddrjs-slp";
|
|
10
|
-
|
|
11
|
-
// export { isValidAddress, isCashAddress, isSlpAddress } from "bchaddrjs-slp";
|
|
12
|
-
|
|
13
|
-
// export function toCashAddress(address: string) {
|
|
14
|
-
// if (["bchreg", "slpreg"].some(val => address.includes(val))) {
|
|
15
|
-
// return bchaddr.toRegtestAddress(bchaddr.toCashAddress(address));
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
// return bchaddr.toCashAddress(address);
|
|
19
|
-
// }
|
|
20
|
-
|
|
21
|
-
// export function toSlpAddress(address: string) {
|
|
22
|
-
// if (["bchreg", "slpreg"].some(val => address.includes(val))) {
|
|
23
|
-
// return bchaddr.toSlpRegtestAddress(address);
|
|
24
|
-
// }
|
|
25
|
-
|
|
26
|
-
// return bchaddr.toSlpAddress(address);
|
|
27
|
-
// }
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
const playwright = require("playwright");
|
|
2
|
-
|
|
3
|
-
const PAGE_URL = "http://localhost:8080";
|
|
4
|
-
|
|
5
|
-
describe.skip(`Wallet should function in the browser`, () => {
|
|
6
|
-
let browser = null;
|
|
7
|
-
let page = null;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Create the browser and page context
|
|
11
|
-
*/
|
|
12
|
-
beforeAll(async () => {
|
|
13
|
-
browser = await playwright["chromium"].launch();
|
|
14
|
-
page = await browser.newPage();
|
|
15
|
-
|
|
16
|
-
if (!page) {
|
|
17
|
-
throw new Error("Connection wasn't established");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Open the page
|
|
21
|
-
await page.goto(PAGE_URL, {
|
|
22
|
-
waitUntil: "networkidle0",
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
afterAll(async () => {
|
|
27
|
-
await browser.close();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
let jestTokenId;
|
|
31
|
-
|
|
32
|
-
test(`Should create slp token`, async () => {
|
|
33
|
-
const result = await page.evaluate(async (wif) => {
|
|
34
|
-
const wallet = await RegTestWallet.fromId(`wif:regtest:${wif}`);
|
|
35
|
-
|
|
36
|
-
let ticker = Math.random().toString(36).substring(8).toUpperCase();
|
|
37
|
-
|
|
38
|
-
const genesisOptions = {
|
|
39
|
-
name: "Mainnet coin",
|
|
40
|
-
ticker: ticker,
|
|
41
|
-
decimals: 2,
|
|
42
|
-
initialAmount: 10000,
|
|
43
|
-
documentUrl: "https://mainnet.cash",
|
|
44
|
-
documentHash:
|
|
45
|
-
"0000000000000000000000000000000000000000000000000000000000000000",
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const { tokenId } = await wallet.slp.genesis(genesisOptions);
|
|
49
|
-
return tokenId;
|
|
50
|
-
}, process.env.PRIVATE_WIF);
|
|
51
|
-
expect(result.length).toBe(64);
|
|
52
|
-
jestTokenId = result;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test(`Should mint extra slp tokens`, async () => {
|
|
56
|
-
const result = await page.evaluate(
|
|
57
|
-
async ([wif, tokenId]) => {
|
|
58
|
-
const wallet = await RegTestWallet.fromId(`wif:regtest:${wif}`);
|
|
59
|
-
|
|
60
|
-
const { balance } = await wallet.slp.mint({
|
|
61
|
-
value: 10,
|
|
62
|
-
tokenId: tokenId,
|
|
63
|
-
endBaton: false,
|
|
64
|
-
});
|
|
65
|
-
return balance;
|
|
66
|
-
},
|
|
67
|
-
[process.env.PRIVATE_WIF, jestTokenId]
|
|
68
|
-
);
|
|
69
|
-
expect(result.value.c[0]).toBe(10010);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test(`Should send slp tokens`, async () => {
|
|
73
|
-
const result = await page.evaluate(
|
|
74
|
-
async ([wif, tokenId]) => {
|
|
75
|
-
const wallet = await RegTestWallet.fromId(`wif:regtest:${wif}`);
|
|
76
|
-
const bobWallet = await RegTestWallet.newRandom();
|
|
77
|
-
|
|
78
|
-
const { balance } = await wallet.slp.send([
|
|
79
|
-
{ slpaddr: bobWallet.slp.slpaddr, value: 10, tokenId: tokenId },
|
|
80
|
-
]);
|
|
81
|
-
return balance;
|
|
82
|
-
},
|
|
83
|
-
[process.env.PRIVATE_WIF, jestTokenId]
|
|
84
|
-
);
|
|
85
|
-
expect(result.value.c[0]).toBe(10000);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test.skip(`Should watch slp testnet balance`, async () => {
|
|
89
|
-
jestTokenId =
|
|
90
|
-
"132731d90ac4c88a79d55eae2ad92709b415de886329e958cf35fdd81ba34c15";
|
|
91
|
-
const result = await page.evaluate(
|
|
92
|
-
async ([wif, tokenId]) => {
|
|
93
|
-
const wallet = await TestNetWallet.fromId(`wif:testnet:${wif}`);
|
|
94
|
-
|
|
95
|
-
// // FIXME: we do not have gspp testnet yet
|
|
96
|
-
// if (wallet.slp.provider instanceof GsppProvider) {
|
|
97
|
-
// console.warn("we do not have gspp testnet yet");
|
|
98
|
-
// }
|
|
99
|
-
|
|
100
|
-
const bobWallet = await TestNetWallet.newRandom();
|
|
101
|
-
|
|
102
|
-
let balance;
|
|
103
|
-
|
|
104
|
-
bobWallet.slp.watchBalance((_balance) => {
|
|
105
|
-
balance = _balance;
|
|
106
|
-
}, tokenId);
|
|
107
|
-
|
|
108
|
-
await wallet.slp.send([
|
|
109
|
-
{ slpaddr: bobWallet.slp.slpaddr, value: 1, tokenId: tokenId },
|
|
110
|
-
]);
|
|
111
|
-
|
|
112
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
113
|
-
|
|
114
|
-
return balance;
|
|
115
|
-
},
|
|
116
|
-
[process.env.FAUCET_SLP_WIF, jestTokenId]
|
|
117
|
-
);
|
|
118
|
-
expect(result.value.c[0]).toBe(1);
|
|
119
|
-
});
|
|
120
|
-
});
|