@dorafactory/maci-sdk 0.1.3-pre.14 → 0.1.3-pre.16
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.js +126 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -3
- package/dist/index.mjs.map +1 -1
- package/dist/libs/maci/maci.d.ts +13 -1
- package/dist/maci.d.ts +14 -2
- package/package.json +1 -1
- package/src/libs/maci/maci.ts +121 -3
- package/src/maci.ts +38 -1
package/dist/index.js
CHANGED
|
@@ -8078,7 +8078,8 @@ var MACI = class {
|
|
|
8078
8078
|
address,
|
|
8079
8079
|
contractAddress,
|
|
8080
8080
|
payload,
|
|
8081
|
-
gasStation,
|
|
8081
|
+
gasStation = false,
|
|
8082
|
+
granter,
|
|
8082
8083
|
fee = 1.8
|
|
8083
8084
|
}) {
|
|
8084
8085
|
try {
|
|
@@ -8122,7 +8123,7 @@ var MACI = class {
|
|
|
8122
8123
|
const grantFee = {
|
|
8123
8124
|
amount: calculatedFee.amount,
|
|
8124
8125
|
gas: calculatedFee.gas,
|
|
8125
|
-
granter: contractAddress
|
|
8126
|
+
granter: granter || contractAddress
|
|
8126
8127
|
};
|
|
8127
8128
|
return client.execute(
|
|
8128
8129
|
address,
|
|
@@ -8133,7 +8134,7 @@ var MACI = class {
|
|
|
8133
8134
|
} else if (gasStation === true && typeof fee === "object") {
|
|
8134
8135
|
const grantFee = {
|
|
8135
8136
|
...fee,
|
|
8136
|
-
granter: contractAddress
|
|
8137
|
+
granter: granter || contractAddress
|
|
8137
8138
|
};
|
|
8138
8139
|
return client.execute(
|
|
8139
8140
|
address,
|
|
@@ -8201,6 +8202,103 @@ var MACI = class {
|
|
|
8201
8202
|
fee
|
|
8202
8203
|
);
|
|
8203
8204
|
}
|
|
8205
|
+
async rawAddNewKey({
|
|
8206
|
+
signer,
|
|
8207
|
+
contractAddress,
|
|
8208
|
+
d,
|
|
8209
|
+
proof,
|
|
8210
|
+
nullifier,
|
|
8211
|
+
newPubkey,
|
|
8212
|
+
gasStation = false,
|
|
8213
|
+
granter,
|
|
8214
|
+
fee = "auto"
|
|
8215
|
+
}) {
|
|
8216
|
+
const client = await this.contract.amaciClient({
|
|
8217
|
+
signer,
|
|
8218
|
+
contractAddress
|
|
8219
|
+
});
|
|
8220
|
+
if (gasStation === true && typeof fee !== "object") {
|
|
8221
|
+
const [{ address }] = await signer.getAccounts();
|
|
8222
|
+
const contractClient = await this.contract.contractClient({ signer });
|
|
8223
|
+
const msg = {
|
|
8224
|
+
add_new_key: {
|
|
8225
|
+
d,
|
|
8226
|
+
groth16_proof: proof,
|
|
8227
|
+
nullifier: nullifier.toString(),
|
|
8228
|
+
pubkey: {
|
|
8229
|
+
x: newPubkey[0].toString(),
|
|
8230
|
+
y: newPubkey[1].toString()
|
|
8231
|
+
}
|
|
8232
|
+
}
|
|
8233
|
+
};
|
|
8234
|
+
const gasEstimation = await contractClient.simulate(
|
|
8235
|
+
address,
|
|
8236
|
+
[
|
|
8237
|
+
{
|
|
8238
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
8239
|
+
value: {
|
|
8240
|
+
sender: address,
|
|
8241
|
+
contract: contractAddress,
|
|
8242
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
8243
|
+
}
|
|
8244
|
+
}
|
|
8245
|
+
],
|
|
8246
|
+
""
|
|
8247
|
+
);
|
|
8248
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
8249
|
+
const gasPrice = import_stargate3.GasPrice.fromString("10000000000peaka");
|
|
8250
|
+
const calculatedFee = (0, import_stargate3.calculateFee)(
|
|
8251
|
+
Math.round(gasEstimation * multiplier),
|
|
8252
|
+
gasPrice
|
|
8253
|
+
);
|
|
8254
|
+
const grantFee = {
|
|
8255
|
+
amount: calculatedFee.amount,
|
|
8256
|
+
gas: calculatedFee.gas,
|
|
8257
|
+
granter: granter || contractAddress
|
|
8258
|
+
};
|
|
8259
|
+
return await client.addNewKey(
|
|
8260
|
+
{
|
|
8261
|
+
d,
|
|
8262
|
+
groth16Proof: proof,
|
|
8263
|
+
nullifier: nullifier.toString(),
|
|
8264
|
+
pubkey: {
|
|
8265
|
+
x: newPubkey[0].toString(),
|
|
8266
|
+
y: newPubkey[1].toString()
|
|
8267
|
+
}
|
|
8268
|
+
},
|
|
8269
|
+
grantFee
|
|
8270
|
+
);
|
|
8271
|
+
} else if (gasStation === true && typeof fee === "object") {
|
|
8272
|
+
const grantFee = {
|
|
8273
|
+
...fee,
|
|
8274
|
+
granter: granter || contractAddress
|
|
8275
|
+
};
|
|
8276
|
+
return await client.addNewKey(
|
|
8277
|
+
{
|
|
8278
|
+
d,
|
|
8279
|
+
groth16Proof: proof,
|
|
8280
|
+
nullifier: nullifier.toString(),
|
|
8281
|
+
pubkey: {
|
|
8282
|
+
x: newPubkey[0].toString(),
|
|
8283
|
+
y: newPubkey[1].toString()
|
|
8284
|
+
}
|
|
8285
|
+
},
|
|
8286
|
+
grantFee
|
|
8287
|
+
);
|
|
8288
|
+
}
|
|
8289
|
+
return await client.addNewKey(
|
|
8290
|
+
{
|
|
8291
|
+
d,
|
|
8292
|
+
groth16Proof: proof,
|
|
8293
|
+
nullifier: nullifier.toString(),
|
|
8294
|
+
pubkey: {
|
|
8295
|
+
x: newPubkey[0].toString(),
|
|
8296
|
+
y: newPubkey[1].toString()
|
|
8297
|
+
}
|
|
8298
|
+
},
|
|
8299
|
+
fee
|
|
8300
|
+
);
|
|
8301
|
+
}
|
|
8204
8302
|
async claimAMaciRound({
|
|
8205
8303
|
signer,
|
|
8206
8304
|
contractAddress,
|
|
@@ -8865,6 +8963,7 @@ var MaciClient2 = class {
|
|
|
8865
8963
|
contractAddress,
|
|
8866
8964
|
payload,
|
|
8867
8965
|
gasStation = false,
|
|
8966
|
+
granter,
|
|
8868
8967
|
fee
|
|
8869
8968
|
}) {
|
|
8870
8969
|
return await this.maci.rawDeactivate({
|
|
@@ -8873,6 +8972,30 @@ var MaciClient2 = class {
|
|
|
8873
8972
|
contractAddress,
|
|
8874
8973
|
payload,
|
|
8875
8974
|
gasStation,
|
|
8975
|
+
granter,
|
|
8976
|
+
fee
|
|
8977
|
+
});
|
|
8978
|
+
}
|
|
8979
|
+
async rawAddNewKey({
|
|
8980
|
+
signer,
|
|
8981
|
+
contractAddress,
|
|
8982
|
+
d,
|
|
8983
|
+
proof,
|
|
8984
|
+
nullifier,
|
|
8985
|
+
newPubkey,
|
|
8986
|
+
gasStation = false,
|
|
8987
|
+
granter,
|
|
8988
|
+
fee
|
|
8989
|
+
}) {
|
|
8990
|
+
return await this.maci.rawAddNewKey({
|
|
8991
|
+
signer: this.getSigner(signer),
|
|
8992
|
+
contractAddress,
|
|
8993
|
+
d,
|
|
8994
|
+
proof,
|
|
8995
|
+
nullifier,
|
|
8996
|
+
newPubkey,
|
|
8997
|
+
gasStation,
|
|
8998
|
+
granter,
|
|
8876
8999
|
fee
|
|
8877
9000
|
});
|
|
8878
9001
|
}
|