@zucchinifi/dapp-sdk 0.1.6 → 0.1.7
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.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +21 -4
- package/dist/index.mjs +21 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -33,6 +33,7 @@ interface ZucchiniProvider {
|
|
|
33
33
|
spendable: string;
|
|
34
34
|
sapling: string;
|
|
35
35
|
orchard: string;
|
|
36
|
+
transparent: string;
|
|
36
37
|
}>;
|
|
37
38
|
getAddresses(): Promise<{
|
|
38
39
|
transparent: string;
|
|
@@ -49,6 +50,7 @@ interface ZucchiniProvider {
|
|
|
49
50
|
isLocked: boolean;
|
|
50
51
|
hasWallet: boolean;
|
|
51
52
|
}>;
|
|
53
|
+
shieldFunds(): Promise<string[]>;
|
|
52
54
|
on(event: string, callback: (data: any) => void): void;
|
|
53
55
|
off(event: string, callback: (data: any) => void): void;
|
|
54
56
|
disconnect(): Promise<void>;
|
|
@@ -255,6 +257,7 @@ declare class ZucchiniSDK {
|
|
|
255
257
|
spendable: string;
|
|
256
258
|
sapling: string;
|
|
257
259
|
orchard: string;
|
|
260
|
+
transparent: string;
|
|
258
261
|
}>;
|
|
259
262
|
getAddresses(): Promise<{
|
|
260
263
|
sapling: string;
|
|
@@ -265,6 +268,10 @@ declare class ZucchiniSDK {
|
|
|
265
268
|
getNetwork(): Promise<{
|
|
266
269
|
network: 'main' | 'test';
|
|
267
270
|
}>;
|
|
271
|
+
/**
|
|
272
|
+
* Shield transparent funds.
|
|
273
|
+
*/
|
|
274
|
+
shieldFunds(): Promise<string[]>;
|
|
268
275
|
/**
|
|
269
276
|
* Send a generic request to the wallet.
|
|
270
277
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ interface ZucchiniProvider {
|
|
|
33
33
|
spendable: string;
|
|
34
34
|
sapling: string;
|
|
35
35
|
orchard: string;
|
|
36
|
+
transparent: string;
|
|
36
37
|
}>;
|
|
37
38
|
getAddresses(): Promise<{
|
|
38
39
|
transparent: string;
|
|
@@ -49,6 +50,7 @@ interface ZucchiniProvider {
|
|
|
49
50
|
isLocked: boolean;
|
|
50
51
|
hasWallet: boolean;
|
|
51
52
|
}>;
|
|
53
|
+
shieldFunds(): Promise<string[]>;
|
|
52
54
|
on(event: string, callback: (data: any) => void): void;
|
|
53
55
|
off(event: string, callback: (data: any) => void): void;
|
|
54
56
|
disconnect(): Promise<void>;
|
|
@@ -255,6 +257,7 @@ declare class ZucchiniSDK {
|
|
|
255
257
|
spendable: string;
|
|
256
258
|
sapling: string;
|
|
257
259
|
orchard: string;
|
|
260
|
+
transparent: string;
|
|
258
261
|
}>;
|
|
259
262
|
getAddresses(): Promise<{
|
|
260
263
|
sapling: string;
|
|
@@ -265,6 +268,10 @@ declare class ZucchiniSDK {
|
|
|
265
268
|
getNetwork(): Promise<{
|
|
266
269
|
network: 'main' | 'test';
|
|
267
270
|
}>;
|
|
271
|
+
/**
|
|
272
|
+
* Shield transparent funds.
|
|
273
|
+
*/
|
|
274
|
+
shieldFunds(): Promise<string[]>;
|
|
268
275
|
/**
|
|
269
276
|
* Send a generic request to the wallet.
|
|
270
277
|
*/
|
package/dist/index.js
CHANGED
|
@@ -66,6 +66,9 @@ function toZats(amount) {
|
|
|
66
66
|
return BigInt(total);
|
|
67
67
|
}
|
|
68
68
|
function fromZats(amount) {
|
|
69
|
+
if (typeof amount === "string" && amount.includes(".")) {
|
|
70
|
+
return amount;
|
|
71
|
+
}
|
|
69
72
|
const zats = BigInt(amount).toString();
|
|
70
73
|
const padded = zats.padStart(9, "0");
|
|
71
74
|
const whole = padded.slice(0, -8);
|
|
@@ -208,13 +211,19 @@ function parseUnifiedAddress(unifiedAddress) {
|
|
|
208
211
|
switch (typeCode) {
|
|
209
212
|
case TYPE_P2PKH:
|
|
210
213
|
if (length !== 20) throw new Error("Invalid P2PKH length");
|
|
211
|
-
const p2pkhPrefix = hrp === "u" ? [28, 184] : [29, 37];
|
|
212
|
-
|
|
214
|
+
const p2pkhPrefix = new Uint8Array(hrp === "u" ? [28, 184] : [29, 37]);
|
|
215
|
+
const p2pkhCombined = new Uint8Array(p2pkhPrefix.length + receiverData.length);
|
|
216
|
+
p2pkhCombined.set(p2pkhPrefix);
|
|
217
|
+
p2pkhCombined.set(receiverData, p2pkhPrefix.length);
|
|
218
|
+
receivers.push({ type: "p2pkh", typeCode, data: receiverData, address: import_bs58check.default.encode(p2pkhCombined) });
|
|
213
219
|
break;
|
|
214
220
|
case TYPE_P2SH:
|
|
215
221
|
if (length !== 20) throw new Error("Invalid P2SH length");
|
|
216
|
-
const p2shPrefix = hrp === "u" ? [28, 189] : [28, 186];
|
|
217
|
-
|
|
222
|
+
const p2shPrefix = new Uint8Array(hrp === "u" ? [28, 189] : [28, 186]);
|
|
223
|
+
const p2shCombined = new Uint8Array(p2shPrefix.length + receiverData.length);
|
|
224
|
+
p2shCombined.set(p2shPrefix);
|
|
225
|
+
p2shCombined.set(receiverData, p2shPrefix.length);
|
|
226
|
+
receivers.push({ type: "p2sh", typeCode, data: receiverData, address: import_bs58check.default.encode(p2shCombined) });
|
|
218
227
|
break;
|
|
219
228
|
case TYPE_SAPLING:
|
|
220
229
|
if (length !== 43) throw new Error("Invalid Sapling length");
|
|
@@ -836,6 +845,14 @@ var ZucchiniSDK = class {
|
|
|
836
845
|
method: "getNetwork"
|
|
837
846
|
});
|
|
838
847
|
}
|
|
848
|
+
/**
|
|
849
|
+
* Shield transparent funds.
|
|
850
|
+
*/
|
|
851
|
+
async shieldFunds() {
|
|
852
|
+
return this.request({
|
|
853
|
+
method: "shieldFunds"
|
|
854
|
+
});
|
|
855
|
+
}
|
|
839
856
|
/**
|
|
840
857
|
* Send a generic request to the wallet.
|
|
841
858
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,9 @@ function toZats(amount) {
|
|
|
17
17
|
return BigInt(total);
|
|
18
18
|
}
|
|
19
19
|
function fromZats(amount) {
|
|
20
|
+
if (typeof amount === "string" && amount.includes(".")) {
|
|
21
|
+
return amount;
|
|
22
|
+
}
|
|
20
23
|
const zats = BigInt(amount).toString();
|
|
21
24
|
const padded = zats.padStart(9, "0");
|
|
22
25
|
const whole = padded.slice(0, -8);
|
|
@@ -159,13 +162,19 @@ function parseUnifiedAddress(unifiedAddress) {
|
|
|
159
162
|
switch (typeCode) {
|
|
160
163
|
case TYPE_P2PKH:
|
|
161
164
|
if (length !== 20) throw new Error("Invalid P2PKH length");
|
|
162
|
-
const p2pkhPrefix = hrp === "u" ? [28, 184] : [29, 37];
|
|
163
|
-
|
|
165
|
+
const p2pkhPrefix = new Uint8Array(hrp === "u" ? [28, 184] : [29, 37]);
|
|
166
|
+
const p2pkhCombined = new Uint8Array(p2pkhPrefix.length + receiverData.length);
|
|
167
|
+
p2pkhCombined.set(p2pkhPrefix);
|
|
168
|
+
p2pkhCombined.set(receiverData, p2pkhPrefix.length);
|
|
169
|
+
receivers.push({ type: "p2pkh", typeCode, data: receiverData, address: bs58check.encode(p2pkhCombined) });
|
|
164
170
|
break;
|
|
165
171
|
case TYPE_P2SH:
|
|
166
172
|
if (length !== 20) throw new Error("Invalid P2SH length");
|
|
167
|
-
const p2shPrefix = hrp === "u" ? [28, 189] : [28, 186];
|
|
168
|
-
|
|
173
|
+
const p2shPrefix = new Uint8Array(hrp === "u" ? [28, 189] : [28, 186]);
|
|
174
|
+
const p2shCombined = new Uint8Array(p2shPrefix.length + receiverData.length);
|
|
175
|
+
p2shCombined.set(p2shPrefix);
|
|
176
|
+
p2shCombined.set(receiverData, p2shPrefix.length);
|
|
177
|
+
receivers.push({ type: "p2sh", typeCode, data: receiverData, address: bs58check.encode(p2shCombined) });
|
|
169
178
|
break;
|
|
170
179
|
case TYPE_SAPLING:
|
|
171
180
|
if (length !== 43) throw new Error("Invalid Sapling length");
|
|
@@ -787,6 +796,14 @@ var ZucchiniSDK = class {
|
|
|
787
796
|
method: "getNetwork"
|
|
788
797
|
});
|
|
789
798
|
}
|
|
799
|
+
/**
|
|
800
|
+
* Shield transparent funds.
|
|
801
|
+
*/
|
|
802
|
+
async shieldFunds() {
|
|
803
|
+
return this.request({
|
|
804
|
+
method: "shieldFunds"
|
|
805
|
+
});
|
|
806
|
+
}
|
|
790
807
|
/**
|
|
791
808
|
* Send a generic request to the wallet.
|
|
792
809
|
*/
|