@0xsequence/relayer 0.41.3 → 0.42.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/dist/0xsequence-relayer.cjs.dev.js +46 -66
- package/dist/0xsequence-relayer.cjs.prod.js +46 -66
- package/dist/0xsequence-relayer.esm.js +47 -67
- package/dist/declarations/src/index.d.ts +0 -1
- package/dist/declarations/src/provider-relayer.d.ts +0 -1
- package/dist/declarations/src/rpc-relayer/index.d.ts +0 -1
- package/dist/declarations/src/rpc-relayer/relayer.gen.d.ts +61 -20
- package/package.json +5 -5
- package/src/index.ts +0 -9
- package/src/provider-relayer.ts +2 -12
- package/src/rpc-relayer/index.ts +0 -40
- package/src/rpc-relayer/relayer.gen.ts +105 -42
|
@@ -202,16 +202,8 @@ class ProviderRelayer extends BaseRelayer {
|
|
|
202
202
|
}))).map(gasLimit => ({
|
|
203
203
|
executed: true,
|
|
204
204
|
succeeded: true,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}));
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async estimateGasLimits(config$1, context, ...transactions) {
|
|
211
|
-
const walletAddr = config.addressOf(config$1, context);
|
|
212
|
-
const results = await this.simulate(walletAddr, ...transactions);
|
|
213
|
-
return transactions.map((t, i) => _extends({}, t, {
|
|
214
|
-
gasLimit: results[i].gasLimit
|
|
205
|
+
gasUsed: ethers.ethers.BigNumber.from(gasLimit).toNumber(),
|
|
206
|
+
gasLimit: ethers.ethers.BigNumber.from(gasLimit).toNumber()
|
|
215
207
|
}));
|
|
216
208
|
}
|
|
217
209
|
|
|
@@ -410,7 +402,7 @@ class LocalRelayer extends ProviderRelayer {
|
|
|
410
402
|
}
|
|
411
403
|
|
|
412
404
|
/* eslint-disable */
|
|
413
|
-
// sequence-relayer v0.4.0
|
|
405
|
+
// sequence-relayer v0.4.0 e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a
|
|
414
406
|
// --
|
|
415
407
|
// This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
|
|
416
408
|
// Do not edit by hand. Update your webrpc schema and re-generate.
|
|
@@ -419,7 +411,7 @@ const WebRPCVersion = 'v1'; // Schema version of your RIDL schema
|
|
|
419
411
|
|
|
420
412
|
const WebRPCSchemaVersion = 'v0.4.0'; // Schema hash generated from your RIDL schema
|
|
421
413
|
|
|
422
|
-
const WebRPCSchemaHash = '
|
|
414
|
+
const WebRPCSchemaHash = 'e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a'; //
|
|
423
415
|
// Types
|
|
424
416
|
//
|
|
425
417
|
|
|
@@ -561,16 +553,6 @@ class Relayer {
|
|
|
561
553
|
});
|
|
562
554
|
};
|
|
563
555
|
|
|
564
|
-
this.updateMetaTxnGasLimits = (args, headers) => {
|
|
565
|
-
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
|
|
566
|
-
return buildResponse(res).then(_data => {
|
|
567
|
-
return {
|
|
568
|
-
payload: _data.payload
|
|
569
|
-
};
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
};
|
|
573
|
-
|
|
574
556
|
this.feeTokens = headers => {
|
|
575
557
|
return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers)).then(res => {
|
|
576
558
|
return buildResponse(res).then(_data => {
|
|
@@ -593,18 +575,19 @@ class Relayer {
|
|
|
593
575
|
});
|
|
594
576
|
};
|
|
595
577
|
|
|
596
|
-
this.
|
|
597
|
-
return this.fetch(this.url('
|
|
578
|
+
this.sentTransactions = (args, headers) => {
|
|
579
|
+
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers)).then(res => {
|
|
598
580
|
return buildResponse(res).then(_data => {
|
|
599
581
|
return {
|
|
600
|
-
|
|
582
|
+
page: _data.page,
|
|
583
|
+
transactions: _data.transactions
|
|
601
584
|
};
|
|
602
585
|
});
|
|
603
586
|
});
|
|
604
587
|
};
|
|
605
588
|
|
|
606
|
-
this.
|
|
607
|
-
return this.fetch(this.url('
|
|
589
|
+
this.pendingTransactions = (args, headers) => {
|
|
590
|
+
return this.fetch(this.url('PendingTransactions'), createHTTPRequest(args, headers)).then(res => {
|
|
608
591
|
return buildResponse(res).then(_data => {
|
|
609
592
|
return {
|
|
610
593
|
page: _data.page,
|
|
@@ -614,12 +597,44 @@ class Relayer {
|
|
|
614
597
|
});
|
|
615
598
|
};
|
|
616
599
|
|
|
617
|
-
this.
|
|
618
|
-
return this.fetch(this.url('
|
|
600
|
+
this.listGasSponsors = (args, headers) => {
|
|
601
|
+
return this.fetch(this.url('ListGasSponsors'), createHTTPRequest(args, headers)).then(res => {
|
|
619
602
|
return buildResponse(res).then(_data => {
|
|
620
603
|
return {
|
|
621
604
|
page: _data.page,
|
|
622
|
-
|
|
605
|
+
gasSponsors: _data.gasSponsors
|
|
606
|
+
};
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
this.addGasSponsor = (args, headers) => {
|
|
612
|
+
return this.fetch(this.url('AddGasSponsor'), createHTTPRequest(args, headers)).then(res => {
|
|
613
|
+
return buildResponse(res).then(_data => {
|
|
614
|
+
return {
|
|
615
|
+
status: _data.status,
|
|
616
|
+
gasSponsor: _data.gasSponsor
|
|
617
|
+
};
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
this.updateGasSponsor = (args, headers) => {
|
|
623
|
+
return this.fetch(this.url('UpdateGasSponsor'), createHTTPRequest(args, headers)).then(res => {
|
|
624
|
+
return buildResponse(res).then(_data => {
|
|
625
|
+
return {
|
|
626
|
+
status: _data.status,
|
|
627
|
+
gasSponsor: _data.gasSponsor
|
|
628
|
+
};
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
this.reportGasSponsorUsage = (args, headers) => {
|
|
634
|
+
return this.fetch(this.url('ReportGasSponsorUsage'), createHTTPRequest(args, headers)).then(res => {
|
|
635
|
+
return buildResponse(res).then(_data => {
|
|
636
|
+
return {
|
|
637
|
+
gasSponsorUsage: _data.gasSponsorUsage
|
|
623
638
|
};
|
|
624
639
|
});
|
|
625
640
|
});
|
|
@@ -746,41 +761,6 @@ class RpcRelayer extends BaseRelayer {
|
|
|
746
761
|
})).results;
|
|
747
762
|
}
|
|
748
763
|
|
|
749
|
-
async estimateGasLimits(config$1, context, ...transactions$1) {
|
|
750
|
-
utils.logger.info(`[rpc-relayer/estimateGasLimits] estimate gas limits request ${JSON.stringify(transactions$1)}`);
|
|
751
|
-
|
|
752
|
-
if (transactions$1.length == 0) {
|
|
753
|
-
return [];
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
const addr = config.addressOf(config$1, context);
|
|
757
|
-
const prevNonce = transactions.readSequenceNonce(...transactions$1); // Set temporal nonce to simulate meta-txn
|
|
758
|
-
|
|
759
|
-
if (prevNonce === undefined) {
|
|
760
|
-
transactions$1 = transactions.appendNonce(transactions$1, await this.getNonce(config$1, context));
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
const coder = ethers.ethers.utils.defaultAbiCoder;
|
|
764
|
-
const encoded = coder.encode([transactions.MetaTransactionsType], [transactions.sequenceTxAbiEncode(transactions$1)]);
|
|
765
|
-
const res = await this.service.updateMetaTxnGasLimits({
|
|
766
|
-
walletAddress: addr,
|
|
767
|
-
walletConfig: {
|
|
768
|
-
address: addr,
|
|
769
|
-
signers: config$1.signers,
|
|
770
|
-
threshold: config$1.threshold,
|
|
771
|
-
chainId: config$1.chainId
|
|
772
|
-
},
|
|
773
|
-
payload: encoded
|
|
774
|
-
});
|
|
775
|
-
const decoded = coder.decode([transactions.MetaTransactionsType], res.payload)[0];
|
|
776
|
-
const modTxns = transactions$1.map((t, i) => _extends({}, t, {
|
|
777
|
-
gasLimit: decoded[i].gasLimit
|
|
778
|
-
}));
|
|
779
|
-
utils.logger.info(`[rpc-relayer/estimateGasLimits] got transactions with gas limits ${JSON.stringify(modTxns)}`); // Remove placeholder nonce if previously defined
|
|
780
|
-
|
|
781
|
-
return prevNonce === undefined ? modTxns : transactions.appendNonce(modTxns, prevNonce);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
764
|
async getFeeOptions(config$1, context, ...transactions$1) {
|
|
785
765
|
// NOTE/TODO: for a given `service` the feeTokens will not change between execution, so we should memoize this value
|
|
786
766
|
// for a short-period of time, perhaps for 1 day or in memory. Perhaps one day we can make this happen automatically
|
|
@@ -969,7 +949,7 @@ class MetaTransactionResponseException {
|
|
|
969
949
|
}
|
|
970
950
|
|
|
971
951
|
function isRelayer(cand) {
|
|
972
|
-
return typeof cand === 'object' && typeof cand.simulate === 'function' && typeof cand.
|
|
952
|
+
return typeof cand === 'object' && typeof cand.simulate === 'function' && typeof cand.getFeeOptions === 'function' && typeof cand.gasRefundOptions === 'function' && typeof cand.getNonce === 'function' && typeof cand.relay === 'function' && typeof cand.wait === 'function';
|
|
973
953
|
}
|
|
974
954
|
|
|
975
955
|
exports.BaseRelayer = BaseRelayer;
|
|
@@ -202,16 +202,8 @@ class ProviderRelayer extends BaseRelayer {
|
|
|
202
202
|
}))).map(gasLimit => ({
|
|
203
203
|
executed: true,
|
|
204
204
|
succeeded: true,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}));
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async estimateGasLimits(config$1, context, ...transactions) {
|
|
211
|
-
const walletAddr = config.addressOf(config$1, context);
|
|
212
|
-
const results = await this.simulate(walletAddr, ...transactions);
|
|
213
|
-
return transactions.map((t, i) => _extends({}, t, {
|
|
214
|
-
gasLimit: results[i].gasLimit
|
|
205
|
+
gasUsed: ethers.ethers.BigNumber.from(gasLimit).toNumber(),
|
|
206
|
+
gasLimit: ethers.ethers.BigNumber.from(gasLimit).toNumber()
|
|
215
207
|
}));
|
|
216
208
|
}
|
|
217
209
|
|
|
@@ -410,7 +402,7 @@ class LocalRelayer extends ProviderRelayer {
|
|
|
410
402
|
}
|
|
411
403
|
|
|
412
404
|
/* eslint-disable */
|
|
413
|
-
// sequence-relayer v0.4.0
|
|
405
|
+
// sequence-relayer v0.4.0 e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a
|
|
414
406
|
// --
|
|
415
407
|
// This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
|
|
416
408
|
// Do not edit by hand. Update your webrpc schema and re-generate.
|
|
@@ -419,7 +411,7 @@ const WebRPCVersion = 'v1'; // Schema version of your RIDL schema
|
|
|
419
411
|
|
|
420
412
|
const WebRPCSchemaVersion = 'v0.4.0'; // Schema hash generated from your RIDL schema
|
|
421
413
|
|
|
422
|
-
const WebRPCSchemaHash = '
|
|
414
|
+
const WebRPCSchemaHash = 'e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a'; //
|
|
423
415
|
// Types
|
|
424
416
|
//
|
|
425
417
|
|
|
@@ -561,16 +553,6 @@ class Relayer {
|
|
|
561
553
|
});
|
|
562
554
|
};
|
|
563
555
|
|
|
564
|
-
this.updateMetaTxnGasLimits = (args, headers) => {
|
|
565
|
-
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
|
|
566
|
-
return buildResponse(res).then(_data => {
|
|
567
|
-
return {
|
|
568
|
-
payload: _data.payload
|
|
569
|
-
};
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
};
|
|
573
|
-
|
|
574
556
|
this.feeTokens = headers => {
|
|
575
557
|
return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers)).then(res => {
|
|
576
558
|
return buildResponse(res).then(_data => {
|
|
@@ -593,18 +575,19 @@ class Relayer {
|
|
|
593
575
|
});
|
|
594
576
|
};
|
|
595
577
|
|
|
596
|
-
this.
|
|
597
|
-
return this.fetch(this.url('
|
|
578
|
+
this.sentTransactions = (args, headers) => {
|
|
579
|
+
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers)).then(res => {
|
|
598
580
|
return buildResponse(res).then(_data => {
|
|
599
581
|
return {
|
|
600
|
-
|
|
582
|
+
page: _data.page,
|
|
583
|
+
transactions: _data.transactions
|
|
601
584
|
};
|
|
602
585
|
});
|
|
603
586
|
});
|
|
604
587
|
};
|
|
605
588
|
|
|
606
|
-
this.
|
|
607
|
-
return this.fetch(this.url('
|
|
589
|
+
this.pendingTransactions = (args, headers) => {
|
|
590
|
+
return this.fetch(this.url('PendingTransactions'), createHTTPRequest(args, headers)).then(res => {
|
|
608
591
|
return buildResponse(res).then(_data => {
|
|
609
592
|
return {
|
|
610
593
|
page: _data.page,
|
|
@@ -614,12 +597,44 @@ class Relayer {
|
|
|
614
597
|
});
|
|
615
598
|
};
|
|
616
599
|
|
|
617
|
-
this.
|
|
618
|
-
return this.fetch(this.url('
|
|
600
|
+
this.listGasSponsors = (args, headers) => {
|
|
601
|
+
return this.fetch(this.url('ListGasSponsors'), createHTTPRequest(args, headers)).then(res => {
|
|
619
602
|
return buildResponse(res).then(_data => {
|
|
620
603
|
return {
|
|
621
604
|
page: _data.page,
|
|
622
|
-
|
|
605
|
+
gasSponsors: _data.gasSponsors
|
|
606
|
+
};
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
this.addGasSponsor = (args, headers) => {
|
|
612
|
+
return this.fetch(this.url('AddGasSponsor'), createHTTPRequest(args, headers)).then(res => {
|
|
613
|
+
return buildResponse(res).then(_data => {
|
|
614
|
+
return {
|
|
615
|
+
status: _data.status,
|
|
616
|
+
gasSponsor: _data.gasSponsor
|
|
617
|
+
};
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
this.updateGasSponsor = (args, headers) => {
|
|
623
|
+
return this.fetch(this.url('UpdateGasSponsor'), createHTTPRequest(args, headers)).then(res => {
|
|
624
|
+
return buildResponse(res).then(_data => {
|
|
625
|
+
return {
|
|
626
|
+
status: _data.status,
|
|
627
|
+
gasSponsor: _data.gasSponsor
|
|
628
|
+
};
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
this.reportGasSponsorUsage = (args, headers) => {
|
|
634
|
+
return this.fetch(this.url('ReportGasSponsorUsage'), createHTTPRequest(args, headers)).then(res => {
|
|
635
|
+
return buildResponse(res).then(_data => {
|
|
636
|
+
return {
|
|
637
|
+
gasSponsorUsage: _data.gasSponsorUsage
|
|
623
638
|
};
|
|
624
639
|
});
|
|
625
640
|
});
|
|
@@ -746,41 +761,6 @@ class RpcRelayer extends BaseRelayer {
|
|
|
746
761
|
})).results;
|
|
747
762
|
}
|
|
748
763
|
|
|
749
|
-
async estimateGasLimits(config$1, context, ...transactions$1) {
|
|
750
|
-
utils.logger.info(`[rpc-relayer/estimateGasLimits] estimate gas limits request ${JSON.stringify(transactions$1)}`);
|
|
751
|
-
|
|
752
|
-
if (transactions$1.length == 0) {
|
|
753
|
-
return [];
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
const addr = config.addressOf(config$1, context);
|
|
757
|
-
const prevNonce = transactions.readSequenceNonce(...transactions$1); // Set temporal nonce to simulate meta-txn
|
|
758
|
-
|
|
759
|
-
if (prevNonce === undefined) {
|
|
760
|
-
transactions$1 = transactions.appendNonce(transactions$1, await this.getNonce(config$1, context));
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
const coder = ethers.ethers.utils.defaultAbiCoder;
|
|
764
|
-
const encoded = coder.encode([transactions.MetaTransactionsType], [transactions.sequenceTxAbiEncode(transactions$1)]);
|
|
765
|
-
const res = await this.service.updateMetaTxnGasLimits({
|
|
766
|
-
walletAddress: addr,
|
|
767
|
-
walletConfig: {
|
|
768
|
-
address: addr,
|
|
769
|
-
signers: config$1.signers,
|
|
770
|
-
threshold: config$1.threshold,
|
|
771
|
-
chainId: config$1.chainId
|
|
772
|
-
},
|
|
773
|
-
payload: encoded
|
|
774
|
-
});
|
|
775
|
-
const decoded = coder.decode([transactions.MetaTransactionsType], res.payload)[0];
|
|
776
|
-
const modTxns = transactions$1.map((t, i) => _extends({}, t, {
|
|
777
|
-
gasLimit: decoded[i].gasLimit
|
|
778
|
-
}));
|
|
779
|
-
utils.logger.info(`[rpc-relayer/estimateGasLimits] got transactions with gas limits ${JSON.stringify(modTxns)}`); // Remove placeholder nonce if previously defined
|
|
780
|
-
|
|
781
|
-
return prevNonce === undefined ? modTxns : transactions.appendNonce(modTxns, prevNonce);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
764
|
async getFeeOptions(config$1, context, ...transactions$1) {
|
|
785
765
|
// NOTE/TODO: for a given `service` the feeTokens will not change between execution, so we should memoize this value
|
|
786
766
|
// for a short-period of time, perhaps for 1 day or in memory. Perhaps one day we can make this happen automatically
|
|
@@ -969,7 +949,7 @@ class MetaTransactionResponseException {
|
|
|
969
949
|
}
|
|
970
950
|
|
|
971
951
|
function isRelayer(cand) {
|
|
972
|
-
return typeof cand === 'object' && typeof cand.simulate === 'function' && typeof cand.
|
|
952
|
+
return typeof cand === 'object' && typeof cand.simulate === 'function' && typeof cand.getFeeOptions === 'function' && typeof cand.gasRefundOptions === 'function' && typeof cand.getNonce === 'function' && typeof cand.relay === 'function' && typeof cand.wait === 'function';
|
|
973
953
|
}
|
|
974
954
|
|
|
975
955
|
exports.BaseRelayer = BaseRelayer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers, providers, Signer } from 'ethers';
|
|
2
2
|
import { walletContracts } from '@0xsequence/abi';
|
|
3
|
-
import { sequenceTxAbiEncode, readSequenceNonce, encodeNonce, computeMetaTxnHash, MetaTransactionsType,
|
|
3
|
+
import { sequenceTxAbiEncode, readSequenceNonce, encodeNonce, computeMetaTxnHash, MetaTransactionsType, decodeNonce } from '@0xsequence/transactions';
|
|
4
4
|
import { isBigNumberish, logger } from '@0xsequence/utils';
|
|
5
5
|
import { Provider } from '@ethersproject/providers';
|
|
6
6
|
import { imageHash, addressOf, encodeSignature, buildStubSignature } from '@0xsequence/config';
|
|
@@ -194,16 +194,8 @@ class ProviderRelayer extends BaseRelayer {
|
|
|
194
194
|
}))).map(gasLimit => ({
|
|
195
195
|
executed: true,
|
|
196
196
|
succeeded: true,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}));
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
async estimateGasLimits(config, context, ...transactions) {
|
|
203
|
-
const walletAddr = addressOf(config, context);
|
|
204
|
-
const results = await this.simulate(walletAddr, ...transactions);
|
|
205
|
-
return transactions.map((t, i) => _extends({}, t, {
|
|
206
|
-
gasLimit: results[i].gasLimit
|
|
197
|
+
gasUsed: ethers.BigNumber.from(gasLimit).toNumber(),
|
|
198
|
+
gasLimit: ethers.BigNumber.from(gasLimit).toNumber()
|
|
207
199
|
}));
|
|
208
200
|
}
|
|
209
201
|
|
|
@@ -402,7 +394,7 @@ class LocalRelayer extends ProviderRelayer {
|
|
|
402
394
|
}
|
|
403
395
|
|
|
404
396
|
/* eslint-disable */
|
|
405
|
-
// sequence-relayer v0.4.0
|
|
397
|
+
// sequence-relayer v0.4.0 e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a
|
|
406
398
|
// --
|
|
407
399
|
// This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
|
|
408
400
|
// Do not edit by hand. Update your webrpc schema and re-generate.
|
|
@@ -411,7 +403,7 @@ const WebRPCVersion = 'v1'; // Schema version of your RIDL schema
|
|
|
411
403
|
|
|
412
404
|
const WebRPCSchemaVersion = 'v0.4.0'; // Schema hash generated from your RIDL schema
|
|
413
405
|
|
|
414
|
-
const WebRPCSchemaHash = '
|
|
406
|
+
const WebRPCSchemaHash = 'e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a'; //
|
|
415
407
|
// Types
|
|
416
408
|
//
|
|
417
409
|
|
|
@@ -553,16 +545,6 @@ class Relayer {
|
|
|
553
545
|
});
|
|
554
546
|
};
|
|
555
547
|
|
|
556
|
-
this.updateMetaTxnGasLimits = (args, headers) => {
|
|
557
|
-
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
|
|
558
|
-
return buildResponse(res).then(_data => {
|
|
559
|
-
return {
|
|
560
|
-
payload: _data.payload
|
|
561
|
-
};
|
|
562
|
-
});
|
|
563
|
-
});
|
|
564
|
-
};
|
|
565
|
-
|
|
566
548
|
this.feeTokens = headers => {
|
|
567
549
|
return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers)).then(res => {
|
|
568
550
|
return buildResponse(res).then(_data => {
|
|
@@ -585,18 +567,19 @@ class Relayer {
|
|
|
585
567
|
});
|
|
586
568
|
};
|
|
587
569
|
|
|
588
|
-
this.
|
|
589
|
-
return this.fetch(this.url('
|
|
570
|
+
this.sentTransactions = (args, headers) => {
|
|
571
|
+
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers)).then(res => {
|
|
590
572
|
return buildResponse(res).then(_data => {
|
|
591
573
|
return {
|
|
592
|
-
|
|
574
|
+
page: _data.page,
|
|
575
|
+
transactions: _data.transactions
|
|
593
576
|
};
|
|
594
577
|
});
|
|
595
578
|
});
|
|
596
579
|
};
|
|
597
580
|
|
|
598
|
-
this.
|
|
599
|
-
return this.fetch(this.url('
|
|
581
|
+
this.pendingTransactions = (args, headers) => {
|
|
582
|
+
return this.fetch(this.url('PendingTransactions'), createHTTPRequest(args, headers)).then(res => {
|
|
600
583
|
return buildResponse(res).then(_data => {
|
|
601
584
|
return {
|
|
602
585
|
page: _data.page,
|
|
@@ -606,12 +589,44 @@ class Relayer {
|
|
|
606
589
|
});
|
|
607
590
|
};
|
|
608
591
|
|
|
609
|
-
this.
|
|
610
|
-
return this.fetch(this.url('
|
|
592
|
+
this.listGasSponsors = (args, headers) => {
|
|
593
|
+
return this.fetch(this.url('ListGasSponsors'), createHTTPRequest(args, headers)).then(res => {
|
|
611
594
|
return buildResponse(res).then(_data => {
|
|
612
595
|
return {
|
|
613
596
|
page: _data.page,
|
|
614
|
-
|
|
597
|
+
gasSponsors: _data.gasSponsors
|
|
598
|
+
};
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
this.addGasSponsor = (args, headers) => {
|
|
604
|
+
return this.fetch(this.url('AddGasSponsor'), createHTTPRequest(args, headers)).then(res => {
|
|
605
|
+
return buildResponse(res).then(_data => {
|
|
606
|
+
return {
|
|
607
|
+
status: _data.status,
|
|
608
|
+
gasSponsor: _data.gasSponsor
|
|
609
|
+
};
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
this.updateGasSponsor = (args, headers) => {
|
|
615
|
+
return this.fetch(this.url('UpdateGasSponsor'), createHTTPRequest(args, headers)).then(res => {
|
|
616
|
+
return buildResponse(res).then(_data => {
|
|
617
|
+
return {
|
|
618
|
+
status: _data.status,
|
|
619
|
+
gasSponsor: _data.gasSponsor
|
|
620
|
+
};
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
this.reportGasSponsorUsage = (args, headers) => {
|
|
626
|
+
return this.fetch(this.url('ReportGasSponsorUsage'), createHTTPRequest(args, headers)).then(res => {
|
|
627
|
+
return buildResponse(res).then(_data => {
|
|
628
|
+
return {
|
|
629
|
+
gasSponsorUsage: _data.gasSponsorUsage
|
|
615
630
|
};
|
|
616
631
|
});
|
|
617
632
|
});
|
|
@@ -738,41 +753,6 @@ class RpcRelayer extends BaseRelayer {
|
|
|
738
753
|
})).results;
|
|
739
754
|
}
|
|
740
755
|
|
|
741
|
-
async estimateGasLimits(config, context, ...transactions) {
|
|
742
|
-
logger.info(`[rpc-relayer/estimateGasLimits] estimate gas limits request ${JSON.stringify(transactions)}`);
|
|
743
|
-
|
|
744
|
-
if (transactions.length == 0) {
|
|
745
|
-
return [];
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
const addr = addressOf(config, context);
|
|
749
|
-
const prevNonce = readSequenceNonce(...transactions); // Set temporal nonce to simulate meta-txn
|
|
750
|
-
|
|
751
|
-
if (prevNonce === undefined) {
|
|
752
|
-
transactions = appendNonce(transactions, await this.getNonce(config, context));
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
const coder = ethers.utils.defaultAbiCoder;
|
|
756
|
-
const encoded = coder.encode([MetaTransactionsType], [sequenceTxAbiEncode(transactions)]);
|
|
757
|
-
const res = await this.service.updateMetaTxnGasLimits({
|
|
758
|
-
walletAddress: addr,
|
|
759
|
-
walletConfig: {
|
|
760
|
-
address: addr,
|
|
761
|
-
signers: config.signers,
|
|
762
|
-
threshold: config.threshold,
|
|
763
|
-
chainId: config.chainId
|
|
764
|
-
},
|
|
765
|
-
payload: encoded
|
|
766
|
-
});
|
|
767
|
-
const decoded = coder.decode([MetaTransactionsType], res.payload)[0];
|
|
768
|
-
const modTxns = transactions.map((t, i) => _extends({}, t, {
|
|
769
|
-
gasLimit: decoded[i].gasLimit
|
|
770
|
-
}));
|
|
771
|
-
logger.info(`[rpc-relayer/estimateGasLimits] got transactions with gas limits ${JSON.stringify(modTxns)}`); // Remove placeholder nonce if previously defined
|
|
772
|
-
|
|
773
|
-
return prevNonce === undefined ? modTxns : appendNonce(modTxns, prevNonce);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
756
|
async getFeeOptions(config, context, ...transactions) {
|
|
777
757
|
// NOTE/TODO: for a given `service` the feeTokens will not change between execution, so we should memoize this value
|
|
778
758
|
// for a short-period of time, perhaps for 1 day or in memory. Perhaps one day we can make this happen automatically
|
|
@@ -961,7 +941,7 @@ class MetaTransactionResponseException {
|
|
|
961
941
|
}
|
|
962
942
|
|
|
963
943
|
function isRelayer(cand) {
|
|
964
|
-
return typeof cand === 'object' && typeof cand.simulate === 'function' && typeof cand.
|
|
944
|
+
return typeof cand === 'object' && typeof cand.simulate === 'function' && typeof cand.getFeeOptions === 'function' && typeof cand.gasRefundOptions === 'function' && typeof cand.getNonce === 'function' && typeof cand.relay === 'function' && typeof cand.wait === 'function';
|
|
965
945
|
}
|
|
966
946
|
|
|
967
947
|
export { BaseRelayer, BaseRelayerDefaults, LocalRelayer, ProviderRelayer, ProviderRelayerDefaults, RpcRelayer, relayer_gen as RpcRelayerProto, isBaseRelayerOptions, isLocalRelayerOptions, isProviderRelayerOptions, isRelayer, isRpcRelayerOptions, relayer_gen as proto };
|
|
@@ -5,7 +5,6 @@ import { WalletConfig } from '@0xsequence/config';
|
|
|
5
5
|
import { proto } from './rpc-relayer';
|
|
6
6
|
export interface Relayer {
|
|
7
7
|
simulate(wallet: string, ...transactions: Transaction[]): Promise<SimulateResult[]>;
|
|
8
|
-
estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]>;
|
|
9
8
|
getFeeOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<{
|
|
10
9
|
options: FeeOption[];
|
|
11
10
|
quote?: FeeQuote;
|
|
@@ -27,7 +27,6 @@ export declare abstract class ProviderRelayer extends BaseRelayer implements Rel
|
|
|
27
27
|
abstract gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<FeeOption[]>;
|
|
28
28
|
abstract relay(signedTxs: SignedTransactions, quote?: FeeQuote, waitForReceipt?: boolean): Promise<TransactionResponse>;
|
|
29
29
|
simulate(wallet: string, ...transactions: Transaction[]): Promise<SimulateResult[]>;
|
|
30
|
-
estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]>;
|
|
31
30
|
getNonce(config: WalletConfig, context: WalletContext, space?: ethers.BigNumberish, blockTag?: BlockTag): Promise<ethers.BigNumberish>;
|
|
32
31
|
wait(metaTxnId: string | SignedTransactions, timeout?: number, delay?: number, maxFails?: number): Promise<providers.TransactionResponse & {
|
|
33
32
|
receipt: providers.TransactionReceipt;
|
|
@@ -15,7 +15,6 @@ export declare class RpcRelayer extends BaseRelayer implements Relayer {
|
|
|
15
15
|
constructor(options: RpcRelayerOptions);
|
|
16
16
|
waitReceipt(metaTxnId: string | SignedTransactions, delay?: number, maxFails?: number, isCancelled?: () => boolean): Promise<proto.GetMetaTxnReceiptReturn>;
|
|
17
17
|
simulate(wallet: string, ...transactions: Transaction[]): Promise<SimulateResult[]>;
|
|
18
|
-
estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]>;
|
|
19
18
|
getFeeOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<{
|
|
20
19
|
options: FeeOption[];
|
|
21
20
|
quote?: FeeQuote;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const WebRPCVersion = "v1";
|
|
2
2
|
export declare const WebRPCSchemaVersion = "v0.4.0";
|
|
3
|
-
export declare const WebRPCSchemaHash = "
|
|
3
|
+
export declare const WebRPCSchemaHash = "e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a";
|
|
4
4
|
export declare enum ETHTxnStatus {
|
|
5
5
|
UNKNOWN = "UNKNOWN",
|
|
6
6
|
DROPPED = "DROPPED",
|
|
@@ -67,6 +67,24 @@ export interface WalletSigner {
|
|
|
67
67
|
address: string;
|
|
68
68
|
weight: number;
|
|
69
69
|
}
|
|
70
|
+
export interface GasSponsor {
|
|
71
|
+
id: number;
|
|
72
|
+
address: string;
|
|
73
|
+
name: string;
|
|
74
|
+
active: boolean;
|
|
75
|
+
updatedAt: string;
|
|
76
|
+
createdAt: string;
|
|
77
|
+
}
|
|
78
|
+
export interface GasSponsorUsage {
|
|
79
|
+
name: string;
|
|
80
|
+
id: number;
|
|
81
|
+
totalGasUsed: number;
|
|
82
|
+
totalTxnFees: number;
|
|
83
|
+
avgGasPrice: number;
|
|
84
|
+
totalTxns: number;
|
|
85
|
+
startTime: string;
|
|
86
|
+
endTime: string;
|
|
87
|
+
}
|
|
70
88
|
export interface MetaTxn {
|
|
71
89
|
walletAddress: string;
|
|
72
90
|
contract: string;
|
|
@@ -96,6 +114,8 @@ export interface MetaTxnLog {
|
|
|
96
114
|
gasLimit: number;
|
|
97
115
|
gasPrice: string;
|
|
98
116
|
gasUsed: number;
|
|
117
|
+
isWhitelisted: boolean;
|
|
118
|
+
gasSponsor?: number;
|
|
99
119
|
updatedAt: string;
|
|
100
120
|
createdAt: string;
|
|
101
121
|
}
|
|
@@ -197,12 +217,14 @@ export interface Relayer {
|
|
|
197
217
|
getMetaTxnNonce(args: GetMetaTxnNonceArgs, headers?: object): Promise<GetMetaTxnNonceReturn>;
|
|
198
218
|
getMetaTxnReceipt(args: GetMetaTxnReceiptArgs, headers?: object): Promise<GetMetaTxnReceiptReturn>;
|
|
199
219
|
simulate(args: SimulateArgs, headers?: object): Promise<SimulateReturn>;
|
|
200
|
-
updateMetaTxnGasLimits(args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn>;
|
|
201
220
|
feeTokens(headers?: object): Promise<FeeTokensReturn>;
|
|
202
221
|
feeOptions(args: FeeOptionsArgs, headers?: object): Promise<FeeOptionsReturn>;
|
|
203
|
-
getMetaTxnNetworkFeeOptions(args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object): Promise<GetMetaTxnNetworkFeeOptionsReturn>;
|
|
204
222
|
sentTransactions(args: SentTransactionsArgs, headers?: object): Promise<SentTransactionsReturn>;
|
|
205
223
|
pendingTransactions(args: PendingTransactionsArgs, headers?: object): Promise<PendingTransactionsReturn>;
|
|
224
|
+
listGasSponsors(args: ListGasSponsorsArgs, headers?: object): Promise<ListGasSponsorsReturn>;
|
|
225
|
+
addGasSponsor(args: AddGasSponsorArgs, headers?: object): Promise<AddGasSponsorReturn>;
|
|
226
|
+
updateGasSponsor(args: UpdateGasSponsorArgs, headers?: object): Promise<UpdateGasSponsorReturn>;
|
|
227
|
+
reportGasSponsorUsage(args: ReportGasSponsorUsageArgs, headers?: object): Promise<ReportGasSponsorUsageReturn>;
|
|
206
228
|
}
|
|
207
229
|
export interface PingArgs {
|
|
208
230
|
}
|
|
@@ -257,14 +279,6 @@ export interface SimulateArgs {
|
|
|
257
279
|
export interface SimulateReturn {
|
|
258
280
|
results: Array<SimulateResult>;
|
|
259
281
|
}
|
|
260
|
-
export interface UpdateMetaTxnGasLimitsArgs {
|
|
261
|
-
walletAddress: string;
|
|
262
|
-
walletConfig: WalletConfig;
|
|
263
|
-
payload: string;
|
|
264
|
-
}
|
|
265
|
-
export interface UpdateMetaTxnGasLimitsReturn {
|
|
266
|
-
payload: string;
|
|
267
|
-
}
|
|
268
282
|
export interface FeeTokensArgs {
|
|
269
283
|
}
|
|
270
284
|
export interface FeeTokensReturn {
|
|
@@ -280,13 +294,6 @@ export interface FeeOptionsReturn {
|
|
|
280
294
|
options: Array<FeeOption>;
|
|
281
295
|
quote?: string;
|
|
282
296
|
}
|
|
283
|
-
export interface GetMetaTxnNetworkFeeOptionsArgs {
|
|
284
|
-
walletConfig: WalletConfig;
|
|
285
|
-
payload: string;
|
|
286
|
-
}
|
|
287
|
-
export interface GetMetaTxnNetworkFeeOptionsReturn {
|
|
288
|
-
options: Array<FeeOption>;
|
|
289
|
-
}
|
|
290
297
|
export interface SentTransactionsArgs {
|
|
291
298
|
filter?: SentTransactionsFilter;
|
|
292
299
|
page?: Page;
|
|
@@ -302,6 +309,38 @@ export interface PendingTransactionsReturn {
|
|
|
302
309
|
page: Page;
|
|
303
310
|
transactions: Array<Transaction>;
|
|
304
311
|
}
|
|
312
|
+
export interface ListGasSponsorsArgs {
|
|
313
|
+
page?: Page;
|
|
314
|
+
}
|
|
315
|
+
export interface ListGasSponsorsReturn {
|
|
316
|
+
page: Page;
|
|
317
|
+
gasSponsors: Array<GasSponsor>;
|
|
318
|
+
}
|
|
319
|
+
export interface AddGasSponsorArgs {
|
|
320
|
+
address: string;
|
|
321
|
+
name?: string;
|
|
322
|
+
active?: boolean;
|
|
323
|
+
}
|
|
324
|
+
export interface AddGasSponsorReturn {
|
|
325
|
+
status: boolean;
|
|
326
|
+
gasSponsor: GasSponsor;
|
|
327
|
+
}
|
|
328
|
+
export interface UpdateGasSponsorArgs {
|
|
329
|
+
address: string;
|
|
330
|
+
name?: string;
|
|
331
|
+
active?: boolean;
|
|
332
|
+
}
|
|
333
|
+
export interface UpdateGasSponsorReturn {
|
|
334
|
+
status: boolean;
|
|
335
|
+
gasSponsor: GasSponsor;
|
|
336
|
+
}
|
|
337
|
+
export interface ReportGasSponsorUsageArgs {
|
|
338
|
+
startTime?: string;
|
|
339
|
+
endTime?: string;
|
|
340
|
+
}
|
|
341
|
+
export interface ReportGasSponsorUsageReturn {
|
|
342
|
+
gasSponsorUsage: Array<GasSponsorUsage>;
|
|
343
|
+
}
|
|
305
344
|
export declare class Relayer implements Relayer {
|
|
306
345
|
protected hostname: string;
|
|
307
346
|
protected fetch: Fetch;
|
|
@@ -317,12 +356,14 @@ export declare class Relayer implements Relayer {
|
|
|
317
356
|
getMetaTxnNonce: (args: GetMetaTxnNonceArgs, headers?: object | undefined) => Promise<GetMetaTxnNonceReturn>;
|
|
318
357
|
getMetaTxnReceipt: (args: GetMetaTxnReceiptArgs, headers?: object | undefined) => Promise<GetMetaTxnReceiptReturn>;
|
|
319
358
|
simulate: (args: SimulateArgs, headers?: object | undefined) => Promise<SimulateReturn>;
|
|
320
|
-
updateMetaTxnGasLimits: (args: UpdateMetaTxnGasLimitsArgs, headers?: object | undefined) => Promise<UpdateMetaTxnGasLimitsReturn>;
|
|
321
359
|
feeTokens: (headers?: object | undefined) => Promise<FeeTokensReturn>;
|
|
322
360
|
feeOptions: (args: FeeOptionsArgs, headers?: object | undefined) => Promise<FeeOptionsReturn>;
|
|
323
|
-
getMetaTxnNetworkFeeOptions: (args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object | undefined) => Promise<GetMetaTxnNetworkFeeOptionsReturn>;
|
|
324
361
|
sentTransactions: (args: SentTransactionsArgs, headers?: object | undefined) => Promise<SentTransactionsReturn>;
|
|
325
362
|
pendingTransactions: (args: PendingTransactionsArgs, headers?: object | undefined) => Promise<PendingTransactionsReturn>;
|
|
363
|
+
listGasSponsors: (args: ListGasSponsorsArgs, headers?: object | undefined) => Promise<ListGasSponsorsReturn>;
|
|
364
|
+
addGasSponsor: (args: AddGasSponsorArgs, headers?: object | undefined) => Promise<AddGasSponsorReturn>;
|
|
365
|
+
updateGasSponsor: (args: UpdateGasSponsorArgs, headers?: object | undefined) => Promise<UpdateGasSponsorReturn>;
|
|
366
|
+
reportGasSponsorUsage: (args: ReportGasSponsorUsageArgs, headers?: object | undefined) => Promise<ReportGasSponsorUsageReturn>;
|
|
326
367
|
}
|
|
327
368
|
export interface WebRPCError extends Error {
|
|
328
369
|
code: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/relayer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"description": "relayer sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/relayer",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"typecheck": "tsc --noEmit"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@0xsequence/abi": "^0.
|
|
21
|
-
"@0xsequence/config": "^0.
|
|
22
|
-
"@0xsequence/transactions": "^0.
|
|
23
|
-
"@0xsequence/utils": "^0.
|
|
20
|
+
"@0xsequence/abi": "^0.42.1",
|
|
21
|
+
"@0xsequence/config": "^0.42.1",
|
|
22
|
+
"@0xsequence/transactions": "^0.42.1",
|
|
23
|
+
"@0xsequence/utils": "^0.42.1",
|
|
24
24
|
"@ethersproject/providers": "^5.5.1",
|
|
25
25
|
"ethers": "^5.5.2",
|
|
26
26
|
"fetch-ponyfill": "^7.1.0"
|
package/src/index.ts
CHANGED
|
@@ -8,14 +8,6 @@ export interface Relayer {
|
|
|
8
8
|
// simulate returns the execution results for a list of transactions.
|
|
9
9
|
simulate(wallet: string, ...transactions: Transaction[]): Promise<SimulateResult[]>
|
|
10
10
|
|
|
11
|
-
// estimateGasLimits will estimate the gas utilization from the transaction
|
|
12
|
-
// before submission.
|
|
13
|
-
estimateGasLimits(
|
|
14
|
-
config: WalletConfig,
|
|
15
|
-
context: WalletContext,
|
|
16
|
-
...transactions: Transaction[]
|
|
17
|
-
): Promise<Transaction[]>
|
|
18
|
-
|
|
19
11
|
// getFeeOptions returns the fee options that the relayer will accept as payment.
|
|
20
12
|
// If a quote is returned, it may be passed back to the relayer for dispatch.
|
|
21
13
|
getFeeOptions(
|
|
@@ -72,7 +64,6 @@ export function isRelayer(cand: any): cand is Relayer {
|
|
|
72
64
|
return (
|
|
73
65
|
typeof cand === 'object' &&
|
|
74
66
|
typeof cand.simulate === 'function' &&
|
|
75
|
-
typeof cand.estimateGasLimits === 'function' &&
|
|
76
67
|
typeof cand.getFeeOptions === 'function' &&
|
|
77
68
|
typeof cand.gasRefundOptions === 'function' &&
|
|
78
69
|
typeof cand.getNonce === 'function' &&
|
package/src/provider-relayer.ts
CHANGED
|
@@ -88,21 +88,11 @@ export abstract class ProviderRelayer extends BaseRelayer implements Relayer {
|
|
|
88
88
|
}))).map(gasLimit => ({
|
|
89
89
|
executed: true,
|
|
90
90
|
succeeded: true,
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
gasUsed: ethers.BigNumber.from(gasLimit).toNumber(),
|
|
92
|
+
gasLimit: ethers.BigNumber.from(gasLimit).toNumber()
|
|
93
93
|
}))
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
async estimateGasLimits(
|
|
97
|
-
config: WalletConfig,
|
|
98
|
-
context: WalletContext,
|
|
99
|
-
...transactions: Transaction[]
|
|
100
|
-
): Promise<Transaction[]> {
|
|
101
|
-
const walletAddr = addressOf(config, context)
|
|
102
|
-
const results = await this.simulate(walletAddr, ...transactions)
|
|
103
|
-
return transactions.map((t, i) => ({ ...t, gasLimit: results[i].gasLimit }))
|
|
104
|
-
}
|
|
105
|
-
|
|
106
96
|
async getNonce(
|
|
107
97
|
config: WalletConfig,
|
|
108
98
|
context: WalletContext,
|
package/src/rpc-relayer/index.ts
CHANGED
|
@@ -99,46 +99,6 @@ export class RpcRelayer extends BaseRelayer implements Relayer {
|
|
|
99
99
|
return (await this.service.simulate({ wallet, transactions: encoded })).results
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
async estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]> {
|
|
103
|
-
logger.info(`[rpc-relayer/estimateGasLimits] estimate gas limits request ${JSON.stringify(transactions)}`)
|
|
104
|
-
|
|
105
|
-
if (transactions.length == 0) {
|
|
106
|
-
return []
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const addr = addressOf(config, context)
|
|
110
|
-
const prevNonce = readSequenceNonce(...transactions)
|
|
111
|
-
|
|
112
|
-
// Set temporal nonce to simulate meta-txn
|
|
113
|
-
if (prevNonce === undefined) {
|
|
114
|
-
transactions = appendNonce(transactions, await this.getNonce(config, context))
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const coder = ethers.utils.defaultAbiCoder
|
|
118
|
-
const encoded = coder.encode([MetaTransactionsType], [sequenceTxAbiEncode(transactions)])
|
|
119
|
-
const res = await this.service.updateMetaTxnGasLimits({
|
|
120
|
-
walletAddress: addr,
|
|
121
|
-
walletConfig: {
|
|
122
|
-
address: addr,
|
|
123
|
-
signers: config.signers,
|
|
124
|
-
threshold: config.threshold,
|
|
125
|
-
chainId: config.chainId
|
|
126
|
-
},
|
|
127
|
-
payload: encoded
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
const decoded = coder.decode([MetaTransactionsType], res.payload)[0]
|
|
131
|
-
const modTxns = transactions.map((t, i) => ({
|
|
132
|
-
...t,
|
|
133
|
-
gasLimit: decoded[i].gasLimit
|
|
134
|
-
}))
|
|
135
|
-
|
|
136
|
-
logger.info(`[rpc-relayer/estimateGasLimits] got transactions with gas limits ${JSON.stringify(modTxns)}`)
|
|
137
|
-
|
|
138
|
-
// Remove placeholder nonce if previously defined
|
|
139
|
-
return prevNonce === undefined ? modTxns : appendNonce(modTxns, prevNonce)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
102
|
async getFeeOptions(
|
|
143
103
|
config: WalletConfig,
|
|
144
104
|
context: WalletContext,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// sequence-relayer v0.4.0
|
|
2
|
+
// sequence-relayer v0.4.0 e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a
|
|
3
3
|
// --
|
|
4
4
|
// This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
|
|
5
5
|
// Do not edit by hand. Update your webrpc schema and re-generate.
|
|
@@ -11,7 +11,7 @@ export const WebRPCVersion = 'v1'
|
|
|
11
11
|
export const WebRPCSchemaVersion = 'v0.4.0'
|
|
12
12
|
|
|
13
13
|
// Schema hash generated from your RIDL schema
|
|
14
|
-
export const WebRPCSchemaHash = '
|
|
14
|
+
export const WebRPCSchemaHash = 'e7d1a1c505a5bcc9189296c17a160c72e1f6ef8a'
|
|
15
15
|
|
|
16
16
|
//
|
|
17
17
|
// Types
|
|
@@ -92,6 +92,26 @@ export interface WalletSigner {
|
|
|
92
92
|
weight: number
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
export interface GasSponsor {
|
|
96
|
+
id: number
|
|
97
|
+
address: string
|
|
98
|
+
name: string
|
|
99
|
+
active: boolean
|
|
100
|
+
updatedAt: string
|
|
101
|
+
createdAt: string
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface GasSponsorUsage {
|
|
105
|
+
name: string
|
|
106
|
+
id: number
|
|
107
|
+
totalGasUsed: number
|
|
108
|
+
totalTxnFees: number
|
|
109
|
+
avgGasPrice: number
|
|
110
|
+
totalTxns: number
|
|
111
|
+
startTime: string
|
|
112
|
+
endTime: string
|
|
113
|
+
}
|
|
114
|
+
|
|
95
115
|
export interface MetaTxn {
|
|
96
116
|
walletAddress: string
|
|
97
117
|
contract: string
|
|
@@ -118,6 +138,8 @@ export interface MetaTxnLog {
|
|
|
118
138
|
gasLimit: number
|
|
119
139
|
gasPrice: string
|
|
120
140
|
gasUsed: number
|
|
141
|
+
isWhitelisted: boolean
|
|
142
|
+
gasSponsor?: number
|
|
121
143
|
updatedAt: string
|
|
122
144
|
createdAt: string
|
|
123
145
|
}
|
|
@@ -230,12 +252,14 @@ export interface Relayer {
|
|
|
230
252
|
getMetaTxnNonce(args: GetMetaTxnNonceArgs, headers?: object): Promise<GetMetaTxnNonceReturn>
|
|
231
253
|
getMetaTxnReceipt(args: GetMetaTxnReceiptArgs, headers?: object): Promise<GetMetaTxnReceiptReturn>
|
|
232
254
|
simulate(args: SimulateArgs, headers?: object): Promise<SimulateReturn>
|
|
233
|
-
updateMetaTxnGasLimits(args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn>
|
|
234
255
|
feeTokens(headers?: object): Promise<FeeTokensReturn>
|
|
235
256
|
feeOptions(args: FeeOptionsArgs, headers?: object): Promise<FeeOptionsReturn>
|
|
236
|
-
getMetaTxnNetworkFeeOptions(args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object): Promise<GetMetaTxnNetworkFeeOptionsReturn>
|
|
237
257
|
sentTransactions(args: SentTransactionsArgs, headers?: object): Promise<SentTransactionsReturn>
|
|
238
258
|
pendingTransactions(args: PendingTransactionsArgs, headers?: object): Promise<PendingTransactionsReturn>
|
|
259
|
+
listGasSponsors(args: ListGasSponsorsArgs, headers?: object): Promise<ListGasSponsorsReturn>
|
|
260
|
+
addGasSponsor(args: AddGasSponsorArgs, headers?: object): Promise<AddGasSponsorReturn>
|
|
261
|
+
updateGasSponsor(args: UpdateGasSponsorArgs, headers?: object): Promise<UpdateGasSponsorReturn>
|
|
262
|
+
reportGasSponsorUsage(args: ReportGasSponsorUsageArgs, headers?: object): Promise<ReportGasSponsorUsageReturn>
|
|
239
263
|
}
|
|
240
264
|
|
|
241
265
|
export interface PingArgs {}
|
|
@@ -295,15 +319,6 @@ export interface SimulateArgs {
|
|
|
295
319
|
export interface SimulateReturn {
|
|
296
320
|
results: Array<SimulateResult>
|
|
297
321
|
}
|
|
298
|
-
export interface UpdateMetaTxnGasLimitsArgs {
|
|
299
|
-
walletAddress: string
|
|
300
|
-
walletConfig: WalletConfig
|
|
301
|
-
payload: string
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
export interface UpdateMetaTxnGasLimitsReturn {
|
|
305
|
-
payload: string
|
|
306
|
-
}
|
|
307
322
|
export interface FeeTokensArgs {}
|
|
308
323
|
|
|
309
324
|
export interface FeeTokensReturn {
|
|
@@ -320,14 +335,6 @@ export interface FeeOptionsReturn {
|
|
|
320
335
|
options: Array<FeeOption>
|
|
321
336
|
quote?: string
|
|
322
337
|
}
|
|
323
|
-
export interface GetMetaTxnNetworkFeeOptionsArgs {
|
|
324
|
-
walletConfig: WalletConfig
|
|
325
|
-
payload: string
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
export interface GetMetaTxnNetworkFeeOptionsReturn {
|
|
329
|
-
options: Array<FeeOption>
|
|
330
|
-
}
|
|
331
338
|
export interface SentTransactionsArgs {
|
|
332
339
|
filter?: SentTransactionsFilter
|
|
333
340
|
page?: Page
|
|
@@ -345,6 +352,42 @@ export interface PendingTransactionsReturn {
|
|
|
345
352
|
page: Page
|
|
346
353
|
transactions: Array<Transaction>
|
|
347
354
|
}
|
|
355
|
+
export interface ListGasSponsorsArgs {
|
|
356
|
+
page?: Page
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export interface ListGasSponsorsReturn {
|
|
360
|
+
page: Page
|
|
361
|
+
gasSponsors: Array<GasSponsor>
|
|
362
|
+
}
|
|
363
|
+
export interface AddGasSponsorArgs {
|
|
364
|
+
address: string
|
|
365
|
+
name?: string
|
|
366
|
+
active?: boolean
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export interface AddGasSponsorReturn {
|
|
370
|
+
status: boolean
|
|
371
|
+
gasSponsor: GasSponsor
|
|
372
|
+
}
|
|
373
|
+
export interface UpdateGasSponsorArgs {
|
|
374
|
+
address: string
|
|
375
|
+
name?: string
|
|
376
|
+
active?: boolean
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export interface UpdateGasSponsorReturn {
|
|
380
|
+
status: boolean
|
|
381
|
+
gasSponsor: GasSponsor
|
|
382
|
+
}
|
|
383
|
+
export interface ReportGasSponsorUsageArgs {
|
|
384
|
+
startTime?: string
|
|
385
|
+
endTime?: string
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface ReportGasSponsorUsageReturn {
|
|
389
|
+
gasSponsorUsage: Array<GasSponsorUsage>
|
|
390
|
+
}
|
|
348
391
|
|
|
349
392
|
//
|
|
350
393
|
// Client
|
|
@@ -454,16 +497,6 @@ export class Relayer implements Relayer {
|
|
|
454
497
|
})
|
|
455
498
|
}
|
|
456
499
|
|
|
457
|
-
updateMetaTxnGasLimits = (args: UpdateMetaTxnGasLimitsArgs, headers?: object): Promise<UpdateMetaTxnGasLimitsReturn> => {
|
|
458
|
-
return this.fetch(this.url('UpdateMetaTxnGasLimits'), createHTTPRequest(args, headers)).then(res => {
|
|
459
|
-
return buildResponse(res).then(_data => {
|
|
460
|
-
return {
|
|
461
|
-
payload: <string>_data.payload
|
|
462
|
-
}
|
|
463
|
-
})
|
|
464
|
-
})
|
|
465
|
-
}
|
|
466
|
-
|
|
467
500
|
feeTokens = (headers?: object): Promise<FeeTokensReturn> => {
|
|
468
501
|
return this.fetch(this.url('FeeTokens'), createHTTPRequest({}, headers)).then(res => {
|
|
469
502
|
return buildResponse(res).then(_data => {
|
|
@@ -486,21 +519,19 @@ export class Relayer implements Relayer {
|
|
|
486
519
|
})
|
|
487
520
|
}
|
|
488
521
|
|
|
489
|
-
|
|
490
|
-
args
|
|
491
|
-
headers?: object
|
|
492
|
-
): Promise<GetMetaTxnNetworkFeeOptionsReturn> => {
|
|
493
|
-
return this.fetch(this.url('GetMetaTxnNetworkFeeOptions'), createHTTPRequest(args, headers)).then(res => {
|
|
522
|
+
sentTransactions = (args: SentTransactionsArgs, headers?: object): Promise<SentTransactionsReturn> => {
|
|
523
|
+
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers)).then(res => {
|
|
494
524
|
return buildResponse(res).then(_data => {
|
|
495
525
|
return {
|
|
496
|
-
|
|
526
|
+
page: <Page>_data.page,
|
|
527
|
+
transactions: <Array<Transaction>>_data.transactions
|
|
497
528
|
}
|
|
498
529
|
})
|
|
499
530
|
})
|
|
500
531
|
}
|
|
501
532
|
|
|
502
|
-
|
|
503
|
-
return this.fetch(this.url('
|
|
533
|
+
pendingTransactions = (args: PendingTransactionsArgs, headers?: object): Promise<PendingTransactionsReturn> => {
|
|
534
|
+
return this.fetch(this.url('PendingTransactions'), createHTTPRequest(args, headers)).then(res => {
|
|
504
535
|
return buildResponse(res).then(_data => {
|
|
505
536
|
return {
|
|
506
537
|
page: <Page>_data.page,
|
|
@@ -510,12 +541,44 @@ export class Relayer implements Relayer {
|
|
|
510
541
|
})
|
|
511
542
|
}
|
|
512
543
|
|
|
513
|
-
|
|
514
|
-
return this.fetch(this.url('
|
|
544
|
+
listGasSponsors = (args: ListGasSponsorsArgs, headers?: object): Promise<ListGasSponsorsReturn> => {
|
|
545
|
+
return this.fetch(this.url('ListGasSponsors'), createHTTPRequest(args, headers)).then(res => {
|
|
515
546
|
return buildResponse(res).then(_data => {
|
|
516
547
|
return {
|
|
517
548
|
page: <Page>_data.page,
|
|
518
|
-
|
|
549
|
+
gasSponsors: <Array<GasSponsor>>_data.gasSponsors
|
|
550
|
+
}
|
|
551
|
+
})
|
|
552
|
+
})
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
addGasSponsor = (args: AddGasSponsorArgs, headers?: object): Promise<AddGasSponsorReturn> => {
|
|
556
|
+
return this.fetch(this.url('AddGasSponsor'), createHTTPRequest(args, headers)).then(res => {
|
|
557
|
+
return buildResponse(res).then(_data => {
|
|
558
|
+
return {
|
|
559
|
+
status: <boolean>_data.status,
|
|
560
|
+
gasSponsor: <GasSponsor>_data.gasSponsor
|
|
561
|
+
}
|
|
562
|
+
})
|
|
563
|
+
})
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
updateGasSponsor = (args: UpdateGasSponsorArgs, headers?: object): Promise<UpdateGasSponsorReturn> => {
|
|
567
|
+
return this.fetch(this.url('UpdateGasSponsor'), createHTTPRequest(args, headers)).then(res => {
|
|
568
|
+
return buildResponse(res).then(_data => {
|
|
569
|
+
return {
|
|
570
|
+
status: <boolean>_data.status,
|
|
571
|
+
gasSponsor: <GasSponsor>_data.gasSponsor
|
|
572
|
+
}
|
|
573
|
+
})
|
|
574
|
+
})
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
reportGasSponsorUsage = (args: ReportGasSponsorUsageArgs, headers?: object): Promise<ReportGasSponsorUsageReturn> => {
|
|
578
|
+
return this.fetch(this.url('ReportGasSponsorUsage'), createHTTPRequest(args, headers)).then(res => {
|
|
579
|
+
return buildResponse(res).then(_data => {
|
|
580
|
+
return {
|
|
581
|
+
gasSponsorUsage: <Array<GasSponsorUsage>>_data.gasSponsorUsage
|
|
519
582
|
}
|
|
520
583
|
})
|
|
521
584
|
})
|