@dorafactory/maci-sdk 0.0.19 → 0.0.20
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/browser.d.mts +14 -1
- package/dist/browser.d.ts +14 -1
- package/dist/browser.js +31 -2
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +31 -2
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +31 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/libs/http/http.ts +2 -1
- package/src/libs/maci/maci.ts +22 -0
- package/src/libs/oracle-certificate/oracle-certificate.ts +16 -0
- package/src/libs/oracle-certificate/types.ts +9 -0
package/dist/browser.d.mts
CHANGED
|
@@ -18,7 +18,7 @@ declare class Http {
|
|
|
18
18
|
private getFetch;
|
|
19
19
|
fetch(url: string, options?: any): Promise<Response>;
|
|
20
20
|
fetchGraphql<T>(query: string, after: string, limit?: number | null): Promise<T>;
|
|
21
|
-
fetchRest(path: string): Promise<any>;
|
|
21
|
+
fetchRest(path: string, options?: any): Promise<any>;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -1540,12 +1540,21 @@ type SignatureResponse = {
|
|
|
1540
1540
|
amount: string;
|
|
1541
1541
|
snapshotHeight: string;
|
|
1542
1542
|
};
|
|
1543
|
+
type FeegrantAllowanceResponse = {
|
|
1544
|
+
granter: string;
|
|
1545
|
+
grantee: string;
|
|
1546
|
+
spend_limit: {
|
|
1547
|
+
denom: string;
|
|
1548
|
+
amount: string;
|
|
1549
|
+
}[];
|
|
1550
|
+
};
|
|
1543
1551
|
|
|
1544
1552
|
declare class OracleCertificate {
|
|
1545
1553
|
private certificateApiEndpoint;
|
|
1546
1554
|
private http;
|
|
1547
1555
|
constructor({ certificateApiEndpoint, http }: OracleCertificateParams);
|
|
1548
1556
|
sign(data: SignatureRequest): Promise<SignatureResponse>;
|
|
1557
|
+
feegrantAllowance(granter: string, grantee: string): Promise<FeegrantAllowanceResponse>;
|
|
1549
1558
|
}
|
|
1550
1559
|
|
|
1551
1560
|
type MixedData<T> = T | Array<MixedData<T>> | {
|
|
@@ -1628,6 +1637,10 @@ declare class MACI {
|
|
|
1628
1637
|
contractAddress: string;
|
|
1629
1638
|
pubKey: bigint[];
|
|
1630
1639
|
}): Promise<number>;
|
|
1640
|
+
feegrantAllowance({ address, contractAddress, }: {
|
|
1641
|
+
address: string;
|
|
1642
|
+
contractAddress: string;
|
|
1643
|
+
}): Promise<FeegrantAllowanceResponse>;
|
|
1631
1644
|
queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
|
|
1632
1645
|
signer: OfflineSigner;
|
|
1633
1646
|
address: string;
|
package/dist/browser.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare class Http {
|
|
|
18
18
|
private getFetch;
|
|
19
19
|
fetch(url: string, options?: any): Promise<Response>;
|
|
20
20
|
fetchGraphql<T>(query: string, after: string, limit?: number | null): Promise<T>;
|
|
21
|
-
fetchRest(path: string): Promise<any>;
|
|
21
|
+
fetchRest(path: string, options?: any): Promise<any>;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -1540,12 +1540,21 @@ type SignatureResponse = {
|
|
|
1540
1540
|
amount: string;
|
|
1541
1541
|
snapshotHeight: string;
|
|
1542
1542
|
};
|
|
1543
|
+
type FeegrantAllowanceResponse = {
|
|
1544
|
+
granter: string;
|
|
1545
|
+
grantee: string;
|
|
1546
|
+
spend_limit: {
|
|
1547
|
+
denom: string;
|
|
1548
|
+
amount: string;
|
|
1549
|
+
}[];
|
|
1550
|
+
};
|
|
1543
1551
|
|
|
1544
1552
|
declare class OracleCertificate {
|
|
1545
1553
|
private certificateApiEndpoint;
|
|
1546
1554
|
private http;
|
|
1547
1555
|
constructor({ certificateApiEndpoint, http }: OracleCertificateParams);
|
|
1548
1556
|
sign(data: SignatureRequest): Promise<SignatureResponse>;
|
|
1557
|
+
feegrantAllowance(granter: string, grantee: string): Promise<FeegrantAllowanceResponse>;
|
|
1549
1558
|
}
|
|
1550
1559
|
|
|
1551
1560
|
type MixedData<T> = T | Array<MixedData<T>> | {
|
|
@@ -1628,6 +1637,10 @@ declare class MACI {
|
|
|
1628
1637
|
contractAddress: string;
|
|
1629
1638
|
pubKey: bigint[];
|
|
1630
1639
|
}): Promise<number>;
|
|
1640
|
+
feegrantAllowance({ address, contractAddress, }: {
|
|
1641
|
+
address: string;
|
|
1642
|
+
contractAddress: string;
|
|
1643
|
+
}): Promise<FeegrantAllowanceResponse>;
|
|
1631
1644
|
queryWhitelistBalanceOf({ signer, address, contractAddress, certificate, mode, }: {
|
|
1632
1645
|
signer: OfflineSigner;
|
|
1633
1646
|
address: string;
|
package/dist/browser.js
CHANGED
|
@@ -25983,11 +25983,12 @@ var Http = class {
|
|
|
25983
25983
|
);
|
|
25984
25984
|
}
|
|
25985
25985
|
}
|
|
25986
|
-
async fetchRest(path) {
|
|
25986
|
+
async fetchRest(path, options) {
|
|
25987
25987
|
try {
|
|
25988
25988
|
const fetchFn = this.getFetch();
|
|
25989
25989
|
const response = await fetchFn(`${this.restEndpoint}${path}`, {
|
|
25990
|
-
...this.defaultOptions
|
|
25990
|
+
...this.defaultOptions,
|
|
25991
|
+
...options
|
|
25991
25992
|
});
|
|
25992
25993
|
if (!response.ok) {
|
|
25993
25994
|
throw new HttpError(
|
|
@@ -29905,6 +29906,16 @@ var OracleCertificate = class {
|
|
|
29905
29906
|
const signatureData = await response.json();
|
|
29906
29907
|
return signatureData;
|
|
29907
29908
|
}
|
|
29909
|
+
async feegrantAllowance(granter, grantee) {
|
|
29910
|
+
const response = await this.http.fetchRest(
|
|
29911
|
+
`/cosmos/feegrant/v1beta1/allowance/${granter}/${grantee}`
|
|
29912
|
+
);
|
|
29913
|
+
return {
|
|
29914
|
+
granter,
|
|
29915
|
+
grantee,
|
|
29916
|
+
spend_limit: response.allowance.allowance.allowance.spend_limit
|
|
29917
|
+
};
|
|
29918
|
+
}
|
|
29908
29919
|
};
|
|
29909
29920
|
|
|
29910
29921
|
// src/libs/circom/index.ts
|
|
@@ -30236,6 +30247,24 @@ var MACI = class {
|
|
|
30236
30247
|
}
|
|
30237
30248
|
return response.data.signUpEvents[0].stateIdx;
|
|
30238
30249
|
}
|
|
30250
|
+
async feegrantAllowance({
|
|
30251
|
+
address,
|
|
30252
|
+
contractAddress
|
|
30253
|
+
}) {
|
|
30254
|
+
try {
|
|
30255
|
+
const response = await this.oracleCertificate.feegrantAllowance(
|
|
30256
|
+
contractAddress,
|
|
30257
|
+
address
|
|
30258
|
+
);
|
|
30259
|
+
return response;
|
|
30260
|
+
} catch (error) {
|
|
30261
|
+
return {
|
|
30262
|
+
granter: contractAddress,
|
|
30263
|
+
grantee: address,
|
|
30264
|
+
spend_limit: []
|
|
30265
|
+
};
|
|
30266
|
+
}
|
|
30267
|
+
}
|
|
30239
30268
|
// only for maci and oracle maci, amaci will set the voice credit when deploy the contract
|
|
30240
30269
|
async queryWhitelistBalanceOf({
|
|
30241
30270
|
signer,
|