@0xsequence/relayer 2.2.5 → 2.2.6
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 +98 -5
- package/dist/0xsequence-relayer.cjs.prod.js +98 -5
- package/dist/0xsequence-relayer.esm.js +98 -5
- package/dist/declarations/src/index.d.ts +7 -0
- package/dist/declarations/src/local-relayer.d.ts +8 -1
- package/dist/declarations/src/provider-relayer.d.ts +8 -1
- package/dist/declarations/src/rpc-relayer/index.d.ts +7 -0
- package/dist/declarations/src/rpc-relayer/relayer.gen.d.ts +47 -19
- package/package.json +6 -6
- package/src/index.ts +11 -0
- package/src/local-relayer.ts +14 -1
- package/src/provider-relayer.ts +12 -1
- package/src/rpc-relayer/index.ts +13 -0
- package/src/rpc-relayer/relayer.gen.ts +141 -25
|
@@ -241,15 +241,29 @@ class LocalRelayer extends ProviderRelayer {
|
|
|
241
241
|
return responsePromise;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
+
async getMetaTransactions(projectId, page) {
|
|
245
|
+
return {
|
|
246
|
+
page: {
|
|
247
|
+
page: 0,
|
|
248
|
+
pageSize: 100
|
|
249
|
+
},
|
|
250
|
+
transactions: []
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async getTransactionCost(projectId, from, to) {
|
|
254
|
+
return {
|
|
255
|
+
cost: 0
|
|
256
|
+
};
|
|
257
|
+
}
|
|
244
258
|
}
|
|
245
259
|
function isAbstractSigner(signer) {
|
|
246
260
|
return signer && typeof signer === 'object' && typeof signer.provider === 'object' && typeof signer.getAddress === 'function' && typeof signer.connect === 'function';
|
|
247
261
|
}
|
|
248
262
|
|
|
249
263
|
/* eslint-disable */
|
|
250
|
-
// sequence-relayer v0.4.1
|
|
264
|
+
// sequence-relayer v0.4.1 dd95e21fa884c6564199bc3dd5f588534827ffe2
|
|
251
265
|
// --
|
|
252
|
-
// Code generated by webrpc-gen@v0.
|
|
266
|
+
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT.
|
|
253
267
|
//
|
|
254
268
|
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
|
|
255
269
|
|
|
@@ -260,7 +274,7 @@ const WebRPCVersion = 'v1';
|
|
|
260
274
|
const WebRPCSchemaVersion = 'v0.4.1';
|
|
261
275
|
|
|
262
276
|
// Schema hash generated from your RIDL schema
|
|
263
|
-
const WebRPCSchemaHash = '
|
|
277
|
+
const WebRPCSchemaHash = 'dd95e21fa884c6564199bc3dd5f588534827ffe2';
|
|
264
278
|
|
|
265
279
|
//
|
|
266
280
|
// Types
|
|
@@ -491,6 +505,19 @@ class Relayer {
|
|
|
491
505
|
});
|
|
492
506
|
});
|
|
493
507
|
};
|
|
508
|
+
this.getTransactionCost = (args, headers, signal) => {
|
|
509
|
+
return this.fetch(this.url('GetTransactionCost'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
510
|
+
return buildResponse(res).then(_data => {
|
|
511
|
+
return {
|
|
512
|
+
cost: _data.cost
|
|
513
|
+
};
|
|
514
|
+
});
|
|
515
|
+
}, error => {
|
|
516
|
+
throw WebrpcRequestFailedError.new({
|
|
517
|
+
cause: `fetch(): ${error.message || ''}`
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
};
|
|
494
521
|
this.sentTransactions = (args, headers, signal) => {
|
|
495
522
|
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
496
523
|
return buildResponse(res).then(_data => {
|
|
@@ -709,7 +736,33 @@ class Relayer {
|
|
|
709
736
|
});
|
|
710
737
|
});
|
|
711
738
|
};
|
|
712
|
-
this.
|
|
739
|
+
this.getProjectBalance = (args, headers, signal) => {
|
|
740
|
+
return this.fetch(this.url('GetProjectBalance'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
741
|
+
return buildResponse(res).then(_data => {
|
|
742
|
+
return {
|
|
743
|
+
balance: _data.balance
|
|
744
|
+
};
|
|
745
|
+
});
|
|
746
|
+
}, error => {
|
|
747
|
+
throw WebrpcRequestFailedError.new({
|
|
748
|
+
cause: `fetch(): ${error.message || ''}`
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
};
|
|
752
|
+
this.adjustProjectBalance = (args, headers, signal) => {
|
|
753
|
+
return this.fetch(this.url('AdjustProjectBalance'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
754
|
+
return buildResponse(res).then(_data => {
|
|
755
|
+
return {
|
|
756
|
+
balance: _data.balance
|
|
757
|
+
};
|
|
758
|
+
});
|
|
759
|
+
}, error => {
|
|
760
|
+
throw WebrpcRequestFailedError.new({
|
|
761
|
+
cause: `fetch(): ${error.message || ''}`
|
|
762
|
+
});
|
|
763
|
+
});
|
|
764
|
+
};
|
|
765
|
+
this.hostname = hostname.replace(/\/*$/, '');
|
|
713
766
|
this.fetch = (input, init) => fetch(input, init);
|
|
714
767
|
}
|
|
715
768
|
url(name) {
|
|
@@ -865,12 +918,24 @@ class MethodNotFoundError extends WebrpcError {
|
|
|
865
918
|
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
866
919
|
}
|
|
867
920
|
}
|
|
921
|
+
class RequestConflictError extends WebrpcError {
|
|
922
|
+
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) {
|
|
923
|
+
super(name, code, message, status, cause);
|
|
924
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
868
927
|
class AbortedError extends WebrpcError {
|
|
869
928
|
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) {
|
|
870
929
|
super(name, code, message, status, cause);
|
|
871
930
|
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
872
931
|
}
|
|
873
932
|
}
|
|
933
|
+
class GeoblockedError extends WebrpcError {
|
|
934
|
+
constructor(name = 'Geoblocked', code = 1006, message = 'Geoblocked region', status = 0, cause) {
|
|
935
|
+
super(name, code, message, status, cause);
|
|
936
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
874
939
|
class InvalidArgumentError extends WebrpcError {
|
|
875
940
|
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) {
|
|
876
941
|
super(name, code, message, status, cause);
|
|
@@ -895,6 +960,12 @@ class NotFoundError extends WebrpcError {
|
|
|
895
960
|
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
896
961
|
}
|
|
897
962
|
}
|
|
963
|
+
class InsufficientFeeError extends WebrpcError {
|
|
964
|
+
constructor(name = 'InsufficientFee', code = 3004, message = 'Insufficient fee', status = 0, cause) {
|
|
965
|
+
super(name, code, message, status, cause);
|
|
966
|
+
Object.setPrototypeOf(this, InsufficientFeeError.prototype);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
898
969
|
let errors = /*#__PURE__*/function (errors) {
|
|
899
970
|
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
900
971
|
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
@@ -910,11 +981,14 @@ let errors = /*#__PURE__*/function (errors) {
|
|
|
910
981
|
errors["Unauthorized"] = "Unauthorized";
|
|
911
982
|
errors["PermissionDenied"] = "PermissionDenied";
|
|
912
983
|
errors["MethodNotFound"] = "MethodNotFound";
|
|
984
|
+
errors["RequestConflict"] = "RequestConflict";
|
|
913
985
|
errors["Aborted"] = "Aborted";
|
|
986
|
+
errors["Geoblocked"] = "Geoblocked";
|
|
914
987
|
errors["InvalidArgument"] = "InvalidArgument";
|
|
915
988
|
errors["Unavailable"] = "Unavailable";
|
|
916
989
|
errors["QueryFailed"] = "QueryFailed";
|
|
917
990
|
errors["NotFound"] = "NotFound";
|
|
991
|
+
errors["InsufficientFee"] = "InsufficientFee";
|
|
918
992
|
return errors;
|
|
919
993
|
}({});
|
|
920
994
|
const webrpcErrorByCode = {
|
|
@@ -932,11 +1006,14 @@ const webrpcErrorByCode = {
|
|
|
932
1006
|
[1000]: UnauthorizedError,
|
|
933
1007
|
[1001]: PermissionDeniedError,
|
|
934
1008
|
[1003]: MethodNotFoundError,
|
|
1009
|
+
[1004]: RequestConflictError,
|
|
935
1010
|
[1005]: AbortedError,
|
|
1011
|
+
[1006]: GeoblockedError,
|
|
936
1012
|
[2001]: InvalidArgumentError,
|
|
937
1013
|
[2002]: UnavailableError,
|
|
938
1014
|
[2003]: QueryFailedError,
|
|
939
|
-
[3000]: NotFoundError
|
|
1015
|
+
[3000]: NotFoundError,
|
|
1016
|
+
[3004]: InsufficientFeeError
|
|
940
1017
|
};
|
|
941
1018
|
|
|
942
1019
|
var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
@@ -964,11 +1041,14 @@ var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
|
964
1041
|
UnauthorizedError: UnauthorizedError,
|
|
965
1042
|
PermissionDeniedError: PermissionDeniedError,
|
|
966
1043
|
MethodNotFoundError: MethodNotFoundError,
|
|
1044
|
+
RequestConflictError: RequestConflictError,
|
|
967
1045
|
AbortedError: AbortedError,
|
|
1046
|
+
GeoblockedError: GeoblockedError,
|
|
968
1047
|
InvalidArgumentError: InvalidArgumentError,
|
|
969
1048
|
UnavailableError: UnavailableError,
|
|
970
1049
|
QueryFailedError: QueryFailedError,
|
|
971
1050
|
NotFoundError: NotFoundError,
|
|
1051
|
+
InsufficientFeeError: InsufficientFeeError,
|
|
972
1052
|
errors: errors
|
|
973
1053
|
});
|
|
974
1054
|
|
|
@@ -1221,6 +1301,19 @@ class RpcRelayer {
|
|
|
1221
1301
|
}
|
|
1222
1302
|
};
|
|
1223
1303
|
}
|
|
1304
|
+
async getMetaTransactions(projectId, page) {
|
|
1305
|
+
return this.service.getMetaTransactions({
|
|
1306
|
+
projectId,
|
|
1307
|
+
page
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
async getTransactionCost(projectId, from, to) {
|
|
1311
|
+
return this.service.getTransactionCost({
|
|
1312
|
+
projectId,
|
|
1313
|
+
from,
|
|
1314
|
+
to
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1224
1317
|
}
|
|
1225
1318
|
class MetaTransactionResponseException {
|
|
1226
1319
|
constructor(receipt) {
|
|
@@ -241,15 +241,29 @@ class LocalRelayer extends ProviderRelayer {
|
|
|
241
241
|
return responsePromise;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
+
async getMetaTransactions(projectId, page) {
|
|
245
|
+
return {
|
|
246
|
+
page: {
|
|
247
|
+
page: 0,
|
|
248
|
+
pageSize: 100
|
|
249
|
+
},
|
|
250
|
+
transactions: []
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async getTransactionCost(projectId, from, to) {
|
|
254
|
+
return {
|
|
255
|
+
cost: 0
|
|
256
|
+
};
|
|
257
|
+
}
|
|
244
258
|
}
|
|
245
259
|
function isAbstractSigner(signer) {
|
|
246
260
|
return signer && typeof signer === 'object' && typeof signer.provider === 'object' && typeof signer.getAddress === 'function' && typeof signer.connect === 'function';
|
|
247
261
|
}
|
|
248
262
|
|
|
249
263
|
/* eslint-disable */
|
|
250
|
-
// sequence-relayer v0.4.1
|
|
264
|
+
// sequence-relayer v0.4.1 dd95e21fa884c6564199bc3dd5f588534827ffe2
|
|
251
265
|
// --
|
|
252
|
-
// Code generated by webrpc-gen@v0.
|
|
266
|
+
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT.
|
|
253
267
|
//
|
|
254
268
|
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
|
|
255
269
|
|
|
@@ -260,7 +274,7 @@ const WebRPCVersion = 'v1';
|
|
|
260
274
|
const WebRPCSchemaVersion = 'v0.4.1';
|
|
261
275
|
|
|
262
276
|
// Schema hash generated from your RIDL schema
|
|
263
|
-
const WebRPCSchemaHash = '
|
|
277
|
+
const WebRPCSchemaHash = 'dd95e21fa884c6564199bc3dd5f588534827ffe2';
|
|
264
278
|
|
|
265
279
|
//
|
|
266
280
|
// Types
|
|
@@ -491,6 +505,19 @@ class Relayer {
|
|
|
491
505
|
});
|
|
492
506
|
});
|
|
493
507
|
};
|
|
508
|
+
this.getTransactionCost = (args, headers, signal) => {
|
|
509
|
+
return this.fetch(this.url('GetTransactionCost'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
510
|
+
return buildResponse(res).then(_data => {
|
|
511
|
+
return {
|
|
512
|
+
cost: _data.cost
|
|
513
|
+
};
|
|
514
|
+
});
|
|
515
|
+
}, error => {
|
|
516
|
+
throw WebrpcRequestFailedError.new({
|
|
517
|
+
cause: `fetch(): ${error.message || ''}`
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
};
|
|
494
521
|
this.sentTransactions = (args, headers, signal) => {
|
|
495
522
|
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
496
523
|
return buildResponse(res).then(_data => {
|
|
@@ -709,7 +736,33 @@ class Relayer {
|
|
|
709
736
|
});
|
|
710
737
|
});
|
|
711
738
|
};
|
|
712
|
-
this.
|
|
739
|
+
this.getProjectBalance = (args, headers, signal) => {
|
|
740
|
+
return this.fetch(this.url('GetProjectBalance'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
741
|
+
return buildResponse(res).then(_data => {
|
|
742
|
+
return {
|
|
743
|
+
balance: _data.balance
|
|
744
|
+
};
|
|
745
|
+
});
|
|
746
|
+
}, error => {
|
|
747
|
+
throw WebrpcRequestFailedError.new({
|
|
748
|
+
cause: `fetch(): ${error.message || ''}`
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
};
|
|
752
|
+
this.adjustProjectBalance = (args, headers, signal) => {
|
|
753
|
+
return this.fetch(this.url('AdjustProjectBalance'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
754
|
+
return buildResponse(res).then(_data => {
|
|
755
|
+
return {
|
|
756
|
+
balance: _data.balance
|
|
757
|
+
};
|
|
758
|
+
});
|
|
759
|
+
}, error => {
|
|
760
|
+
throw WebrpcRequestFailedError.new({
|
|
761
|
+
cause: `fetch(): ${error.message || ''}`
|
|
762
|
+
});
|
|
763
|
+
});
|
|
764
|
+
};
|
|
765
|
+
this.hostname = hostname.replace(/\/*$/, '');
|
|
713
766
|
this.fetch = (input, init) => fetch(input, init);
|
|
714
767
|
}
|
|
715
768
|
url(name) {
|
|
@@ -865,12 +918,24 @@ class MethodNotFoundError extends WebrpcError {
|
|
|
865
918
|
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
866
919
|
}
|
|
867
920
|
}
|
|
921
|
+
class RequestConflictError extends WebrpcError {
|
|
922
|
+
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) {
|
|
923
|
+
super(name, code, message, status, cause);
|
|
924
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
868
927
|
class AbortedError extends WebrpcError {
|
|
869
928
|
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) {
|
|
870
929
|
super(name, code, message, status, cause);
|
|
871
930
|
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
872
931
|
}
|
|
873
932
|
}
|
|
933
|
+
class GeoblockedError extends WebrpcError {
|
|
934
|
+
constructor(name = 'Geoblocked', code = 1006, message = 'Geoblocked region', status = 0, cause) {
|
|
935
|
+
super(name, code, message, status, cause);
|
|
936
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
874
939
|
class InvalidArgumentError extends WebrpcError {
|
|
875
940
|
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) {
|
|
876
941
|
super(name, code, message, status, cause);
|
|
@@ -895,6 +960,12 @@ class NotFoundError extends WebrpcError {
|
|
|
895
960
|
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
896
961
|
}
|
|
897
962
|
}
|
|
963
|
+
class InsufficientFeeError extends WebrpcError {
|
|
964
|
+
constructor(name = 'InsufficientFee', code = 3004, message = 'Insufficient fee', status = 0, cause) {
|
|
965
|
+
super(name, code, message, status, cause);
|
|
966
|
+
Object.setPrototypeOf(this, InsufficientFeeError.prototype);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
898
969
|
let errors = /*#__PURE__*/function (errors) {
|
|
899
970
|
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
900
971
|
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
@@ -910,11 +981,14 @@ let errors = /*#__PURE__*/function (errors) {
|
|
|
910
981
|
errors["Unauthorized"] = "Unauthorized";
|
|
911
982
|
errors["PermissionDenied"] = "PermissionDenied";
|
|
912
983
|
errors["MethodNotFound"] = "MethodNotFound";
|
|
984
|
+
errors["RequestConflict"] = "RequestConflict";
|
|
913
985
|
errors["Aborted"] = "Aborted";
|
|
986
|
+
errors["Geoblocked"] = "Geoblocked";
|
|
914
987
|
errors["InvalidArgument"] = "InvalidArgument";
|
|
915
988
|
errors["Unavailable"] = "Unavailable";
|
|
916
989
|
errors["QueryFailed"] = "QueryFailed";
|
|
917
990
|
errors["NotFound"] = "NotFound";
|
|
991
|
+
errors["InsufficientFee"] = "InsufficientFee";
|
|
918
992
|
return errors;
|
|
919
993
|
}({});
|
|
920
994
|
const webrpcErrorByCode = {
|
|
@@ -932,11 +1006,14 @@ const webrpcErrorByCode = {
|
|
|
932
1006
|
[1000]: UnauthorizedError,
|
|
933
1007
|
[1001]: PermissionDeniedError,
|
|
934
1008
|
[1003]: MethodNotFoundError,
|
|
1009
|
+
[1004]: RequestConflictError,
|
|
935
1010
|
[1005]: AbortedError,
|
|
1011
|
+
[1006]: GeoblockedError,
|
|
936
1012
|
[2001]: InvalidArgumentError,
|
|
937
1013
|
[2002]: UnavailableError,
|
|
938
1014
|
[2003]: QueryFailedError,
|
|
939
|
-
[3000]: NotFoundError
|
|
1015
|
+
[3000]: NotFoundError,
|
|
1016
|
+
[3004]: InsufficientFeeError
|
|
940
1017
|
};
|
|
941
1018
|
|
|
942
1019
|
var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
@@ -964,11 +1041,14 @@ var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
|
964
1041
|
UnauthorizedError: UnauthorizedError,
|
|
965
1042
|
PermissionDeniedError: PermissionDeniedError,
|
|
966
1043
|
MethodNotFoundError: MethodNotFoundError,
|
|
1044
|
+
RequestConflictError: RequestConflictError,
|
|
967
1045
|
AbortedError: AbortedError,
|
|
1046
|
+
GeoblockedError: GeoblockedError,
|
|
968
1047
|
InvalidArgumentError: InvalidArgumentError,
|
|
969
1048
|
UnavailableError: UnavailableError,
|
|
970
1049
|
QueryFailedError: QueryFailedError,
|
|
971
1050
|
NotFoundError: NotFoundError,
|
|
1051
|
+
InsufficientFeeError: InsufficientFeeError,
|
|
972
1052
|
errors: errors
|
|
973
1053
|
});
|
|
974
1054
|
|
|
@@ -1221,6 +1301,19 @@ class RpcRelayer {
|
|
|
1221
1301
|
}
|
|
1222
1302
|
};
|
|
1223
1303
|
}
|
|
1304
|
+
async getMetaTransactions(projectId, page) {
|
|
1305
|
+
return this.service.getMetaTransactions({
|
|
1306
|
+
projectId,
|
|
1307
|
+
page
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
async getTransactionCost(projectId, from, to) {
|
|
1311
|
+
return this.service.getTransactionCost({
|
|
1312
|
+
projectId,
|
|
1313
|
+
from,
|
|
1314
|
+
to
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1224
1317
|
}
|
|
1225
1318
|
class MetaTransactionResponseException {
|
|
1226
1319
|
constructor(receipt) {
|
|
@@ -237,15 +237,29 @@ class LocalRelayer extends ProviderRelayer {
|
|
|
237
237
|
return responsePromise;
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
+
async getMetaTransactions(projectId, page) {
|
|
241
|
+
return {
|
|
242
|
+
page: {
|
|
243
|
+
page: 0,
|
|
244
|
+
pageSize: 100
|
|
245
|
+
},
|
|
246
|
+
transactions: []
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
async getTransactionCost(projectId, from, to) {
|
|
250
|
+
return {
|
|
251
|
+
cost: 0
|
|
252
|
+
};
|
|
253
|
+
}
|
|
240
254
|
}
|
|
241
255
|
function isAbstractSigner(signer) {
|
|
242
256
|
return signer && typeof signer === 'object' && typeof signer.provider === 'object' && typeof signer.getAddress === 'function' && typeof signer.connect === 'function';
|
|
243
257
|
}
|
|
244
258
|
|
|
245
259
|
/* eslint-disable */
|
|
246
|
-
// sequence-relayer v0.4.1
|
|
260
|
+
// sequence-relayer v0.4.1 dd95e21fa884c6564199bc3dd5f588534827ffe2
|
|
247
261
|
// --
|
|
248
|
-
// Code generated by webrpc-gen@v0.
|
|
262
|
+
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT.
|
|
249
263
|
//
|
|
250
264
|
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
|
|
251
265
|
|
|
@@ -256,7 +270,7 @@ const WebRPCVersion = 'v1';
|
|
|
256
270
|
const WebRPCSchemaVersion = 'v0.4.1';
|
|
257
271
|
|
|
258
272
|
// Schema hash generated from your RIDL schema
|
|
259
|
-
const WebRPCSchemaHash = '
|
|
273
|
+
const WebRPCSchemaHash = 'dd95e21fa884c6564199bc3dd5f588534827ffe2';
|
|
260
274
|
|
|
261
275
|
//
|
|
262
276
|
// Types
|
|
@@ -487,6 +501,19 @@ class Relayer {
|
|
|
487
501
|
});
|
|
488
502
|
});
|
|
489
503
|
};
|
|
504
|
+
this.getTransactionCost = (args, headers, signal) => {
|
|
505
|
+
return this.fetch(this.url('GetTransactionCost'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
506
|
+
return buildResponse(res).then(_data => {
|
|
507
|
+
return {
|
|
508
|
+
cost: _data.cost
|
|
509
|
+
};
|
|
510
|
+
});
|
|
511
|
+
}, error => {
|
|
512
|
+
throw WebrpcRequestFailedError.new({
|
|
513
|
+
cause: `fetch(): ${error.message || ''}`
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
};
|
|
490
517
|
this.sentTransactions = (args, headers, signal) => {
|
|
491
518
|
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
492
519
|
return buildResponse(res).then(_data => {
|
|
@@ -705,7 +732,33 @@ class Relayer {
|
|
|
705
732
|
});
|
|
706
733
|
});
|
|
707
734
|
};
|
|
708
|
-
this.
|
|
735
|
+
this.getProjectBalance = (args, headers, signal) => {
|
|
736
|
+
return this.fetch(this.url('GetProjectBalance'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
737
|
+
return buildResponse(res).then(_data => {
|
|
738
|
+
return {
|
|
739
|
+
balance: _data.balance
|
|
740
|
+
};
|
|
741
|
+
});
|
|
742
|
+
}, error => {
|
|
743
|
+
throw WebrpcRequestFailedError.new({
|
|
744
|
+
cause: `fetch(): ${error.message || ''}`
|
|
745
|
+
});
|
|
746
|
+
});
|
|
747
|
+
};
|
|
748
|
+
this.adjustProjectBalance = (args, headers, signal) => {
|
|
749
|
+
return this.fetch(this.url('AdjustProjectBalance'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
750
|
+
return buildResponse(res).then(_data => {
|
|
751
|
+
return {
|
|
752
|
+
balance: _data.balance
|
|
753
|
+
};
|
|
754
|
+
});
|
|
755
|
+
}, error => {
|
|
756
|
+
throw WebrpcRequestFailedError.new({
|
|
757
|
+
cause: `fetch(): ${error.message || ''}`
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
};
|
|
761
|
+
this.hostname = hostname.replace(/\/*$/, '');
|
|
709
762
|
this.fetch = (input, init) => fetch(input, init);
|
|
710
763
|
}
|
|
711
764
|
url(name) {
|
|
@@ -861,12 +914,24 @@ class MethodNotFoundError extends WebrpcError {
|
|
|
861
914
|
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
862
915
|
}
|
|
863
916
|
}
|
|
917
|
+
class RequestConflictError extends WebrpcError {
|
|
918
|
+
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) {
|
|
919
|
+
super(name, code, message, status, cause);
|
|
920
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
864
923
|
class AbortedError extends WebrpcError {
|
|
865
924
|
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) {
|
|
866
925
|
super(name, code, message, status, cause);
|
|
867
926
|
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
868
927
|
}
|
|
869
928
|
}
|
|
929
|
+
class GeoblockedError extends WebrpcError {
|
|
930
|
+
constructor(name = 'Geoblocked', code = 1006, message = 'Geoblocked region', status = 0, cause) {
|
|
931
|
+
super(name, code, message, status, cause);
|
|
932
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
870
935
|
class InvalidArgumentError extends WebrpcError {
|
|
871
936
|
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) {
|
|
872
937
|
super(name, code, message, status, cause);
|
|
@@ -891,6 +956,12 @@ class NotFoundError extends WebrpcError {
|
|
|
891
956
|
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
892
957
|
}
|
|
893
958
|
}
|
|
959
|
+
class InsufficientFeeError extends WebrpcError {
|
|
960
|
+
constructor(name = 'InsufficientFee', code = 3004, message = 'Insufficient fee', status = 0, cause) {
|
|
961
|
+
super(name, code, message, status, cause);
|
|
962
|
+
Object.setPrototypeOf(this, InsufficientFeeError.prototype);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
894
965
|
let errors = /*#__PURE__*/function (errors) {
|
|
895
966
|
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
896
967
|
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
@@ -906,11 +977,14 @@ let errors = /*#__PURE__*/function (errors) {
|
|
|
906
977
|
errors["Unauthorized"] = "Unauthorized";
|
|
907
978
|
errors["PermissionDenied"] = "PermissionDenied";
|
|
908
979
|
errors["MethodNotFound"] = "MethodNotFound";
|
|
980
|
+
errors["RequestConflict"] = "RequestConflict";
|
|
909
981
|
errors["Aborted"] = "Aborted";
|
|
982
|
+
errors["Geoblocked"] = "Geoblocked";
|
|
910
983
|
errors["InvalidArgument"] = "InvalidArgument";
|
|
911
984
|
errors["Unavailable"] = "Unavailable";
|
|
912
985
|
errors["QueryFailed"] = "QueryFailed";
|
|
913
986
|
errors["NotFound"] = "NotFound";
|
|
987
|
+
errors["InsufficientFee"] = "InsufficientFee";
|
|
914
988
|
return errors;
|
|
915
989
|
}({});
|
|
916
990
|
const webrpcErrorByCode = {
|
|
@@ -928,11 +1002,14 @@ const webrpcErrorByCode = {
|
|
|
928
1002
|
[1000]: UnauthorizedError,
|
|
929
1003
|
[1001]: PermissionDeniedError,
|
|
930
1004
|
[1003]: MethodNotFoundError,
|
|
1005
|
+
[1004]: RequestConflictError,
|
|
931
1006
|
[1005]: AbortedError,
|
|
1007
|
+
[1006]: GeoblockedError,
|
|
932
1008
|
[2001]: InvalidArgumentError,
|
|
933
1009
|
[2002]: UnavailableError,
|
|
934
1010
|
[2003]: QueryFailedError,
|
|
935
|
-
[3000]: NotFoundError
|
|
1011
|
+
[3000]: NotFoundError,
|
|
1012
|
+
[3004]: InsufficientFeeError
|
|
936
1013
|
};
|
|
937
1014
|
|
|
938
1015
|
var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
@@ -960,11 +1037,14 @@ var relayer_gen = /*#__PURE__*/Object.freeze({
|
|
|
960
1037
|
UnauthorizedError: UnauthorizedError,
|
|
961
1038
|
PermissionDeniedError: PermissionDeniedError,
|
|
962
1039
|
MethodNotFoundError: MethodNotFoundError,
|
|
1040
|
+
RequestConflictError: RequestConflictError,
|
|
963
1041
|
AbortedError: AbortedError,
|
|
1042
|
+
GeoblockedError: GeoblockedError,
|
|
964
1043
|
InvalidArgumentError: InvalidArgumentError,
|
|
965
1044
|
UnavailableError: UnavailableError,
|
|
966
1045
|
QueryFailedError: QueryFailedError,
|
|
967
1046
|
NotFoundError: NotFoundError,
|
|
1047
|
+
InsufficientFeeError: InsufficientFeeError,
|
|
968
1048
|
errors: errors
|
|
969
1049
|
});
|
|
970
1050
|
|
|
@@ -1217,6 +1297,19 @@ class RpcRelayer {
|
|
|
1217
1297
|
}
|
|
1218
1298
|
};
|
|
1219
1299
|
}
|
|
1300
|
+
async getMetaTransactions(projectId, page) {
|
|
1301
|
+
return this.service.getMetaTransactions({
|
|
1302
|
+
projectId,
|
|
1303
|
+
page
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
async getTransactionCost(projectId, from, to) {
|
|
1307
|
+
return this.service.getTransactionCost({
|
|
1308
|
+
projectId,
|
|
1309
|
+
from,
|
|
1310
|
+
to
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1220
1313
|
}
|
|
1221
1314
|
class MetaTransactionResponseException {
|
|
1222
1315
|
constructor(receipt) {
|
|
@@ -17,6 +17,13 @@ export interface Relayer {
|
|
|
17
17
|
getNonce(address: string, space?: ethers.BigNumberish, blockTag?: ethers.BlockTag): Promise<ethers.BigNumberish>;
|
|
18
18
|
relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean, projectAccessKey?: string): Promise<commons.transaction.TransactionResponse>;
|
|
19
19
|
wait(metaTxnId: string | commons.transaction.SignedTransactionBundle, timeout?: number, delay?: number, maxFails?: number): Promise<commons.transaction.TransactionResponse>;
|
|
20
|
+
getMetaTransactions(projectId: number, page?: proto.Page): Promise<{
|
|
21
|
+
page: proto.Page;
|
|
22
|
+
transactions: proto.MetaTxnLog[];
|
|
23
|
+
}>;
|
|
24
|
+
getTransactionCost(projectId: number, from: string, to: string): Promise<{
|
|
25
|
+
cost: number;
|
|
26
|
+
}>;
|
|
20
27
|
}
|
|
21
28
|
export * from "./local-relayer.js";
|
|
22
29
|
export * from "./provider-relayer.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { FeeOption, FeeQuote, Relayer } from "./index.js";
|
|
2
|
+
import { FeeOption, FeeQuote, proto, Relayer } from "./index.js";
|
|
3
3
|
import { ProviderRelayer, ProviderRelayerOptions } from "./provider-relayer.js";
|
|
4
4
|
import { commons } from '@0xsequence/core';
|
|
5
5
|
export type LocalRelayerOptions = Omit<ProviderRelayerOptions, 'provider'> & {
|
|
@@ -21,4 +21,11 @@ export declare class LocalRelayer extends ProviderRelayer implements Relayer {
|
|
|
21
21
|
gasRefundOptions(address: string, ...transactions: commons.transaction.Transaction[]): Promise<FeeOption[]>;
|
|
22
22
|
setTransactionOptions(transactionRequest: ethers.TransactionRequest): void;
|
|
23
23
|
relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean): Promise<commons.transaction.TransactionResponse<ethers.TransactionReceipt>>;
|
|
24
|
+
getMetaTransactions(projectId: number, page?: proto.Page): Promise<{
|
|
25
|
+
page: proto.Page;
|
|
26
|
+
transactions: proto.MetaTxnLog[];
|
|
27
|
+
}>;
|
|
28
|
+
getTransactionCost(projectId: number, from: string, to: string): Promise<{
|
|
29
|
+
cost: number;
|
|
30
|
+
}>;
|
|
24
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { FeeOption, FeeQuote, Relayer, SimulateResult } from "./index.js";
|
|
2
|
+
import { FeeOption, FeeQuote, proto, Relayer, SimulateResult } from "./index.js";
|
|
3
3
|
import { Optionals } from '@0xsequence/utils';
|
|
4
4
|
import { commons } from '@0xsequence/core';
|
|
5
5
|
export interface ProviderRelayerOptions {
|
|
@@ -28,6 +28,13 @@ export declare abstract class ProviderRelayer implements Relayer {
|
|
|
28
28
|
}>;
|
|
29
29
|
abstract gasRefundOptions(address: string, ...transactions: commons.transaction.Transaction[]): Promise<FeeOption[]>;
|
|
30
30
|
abstract relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean): Promise<commons.transaction.TransactionResponse>;
|
|
31
|
+
abstract getTransactionCost(projectId: number, from: string, to: string): Promise<{
|
|
32
|
+
cost: number;
|
|
33
|
+
}>;
|
|
34
|
+
abstract getMetaTransactions(projectId: number, page?: proto.Page): Promise<{
|
|
35
|
+
page: proto.Page;
|
|
36
|
+
transactions: proto.MetaTxnLog[];
|
|
37
|
+
}>;
|
|
31
38
|
simulate(wallet: string, ...transactions: commons.transaction.Transaction[]): Promise<SimulateResult[]>;
|
|
32
39
|
getNonce(address: string, space?: ethers.BigNumberish, blockTag?: ethers.BlockTag): Promise<ethers.BigNumberish>;
|
|
33
40
|
wait(metaTxnId: string | commons.transaction.SignedTransactionBundle, timeoutDuration?: number, delay?: number, maxFails?: number): Promise<ethers.TransactionResponse & {
|
|
@@ -35,6 +35,13 @@ export declare class RpcRelayer implements Relayer {
|
|
|
35
35
|
getNonce(address: string, space?: ethers.BigNumberish): Promise<ethers.BigNumberish>;
|
|
36
36
|
relay(signedTxs: commons.transaction.IntendedTransactionBundle, quote?: FeeQuote, waitForReceipt?: boolean, projectAccessKey?: string): Promise<commons.transaction.TransactionResponse<RelayerTxReceipt>>;
|
|
37
37
|
wait(metaTxnId: string | commons.transaction.SignedTransactionBundle, timeout?: number, delay?: number, maxFails?: number): Promise<commons.transaction.TransactionResponse<RelayerTxReceipt>>;
|
|
38
|
+
getMetaTransactions(projectId: number, page?: proto.Page): Promise<{
|
|
39
|
+
page: proto.Page;
|
|
40
|
+
transactions: proto.MetaTxnLog[];
|
|
41
|
+
}>;
|
|
42
|
+
getTransactionCost(projectId: number, from: string, to: string): Promise<{
|
|
43
|
+
cost: number;
|
|
44
|
+
}>;
|
|
38
45
|
}
|
|
39
46
|
export type RelayerTxReceipt = {
|
|
40
47
|
blockHash: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const WebRPCVersion = "v1";
|
|
2
2
|
export declare const WebRPCSchemaVersion = "v0.4.1";
|
|
3
|
-
export declare const WebRPCSchemaHash = "
|
|
3
|
+
export declare const WebRPCSchemaHash = "dd95e21fa884c6564199bc3dd5f588534827ffe2";
|
|
4
4
|
export declare enum ETHTxnStatus {
|
|
5
5
|
UNKNOWN = "UNKNOWN",
|
|
6
6
|
DROPPED = "DROPPED",
|
|
@@ -40,10 +40,10 @@ export interface RuntimeStatus {
|
|
|
40
40
|
ver: string;
|
|
41
41
|
branch: string;
|
|
42
42
|
commitHash: string;
|
|
43
|
+
chainID: number;
|
|
43
44
|
useEIP1559: boolean;
|
|
44
45
|
senders: Array<SenderStatus>;
|
|
45
46
|
checks: RuntimeChecks;
|
|
46
|
-
numTxnsRelayed: NumTxnsRelayed;
|
|
47
47
|
}
|
|
48
48
|
export interface SenderStatus {
|
|
49
49
|
index: number;
|
|
@@ -53,11 +53,6 @@ export interface SenderStatus {
|
|
|
53
53
|
}
|
|
54
54
|
export interface RuntimeChecks {
|
|
55
55
|
}
|
|
56
|
-
export interface NumTxnsRelayed {
|
|
57
|
-
prev: number;
|
|
58
|
-
current: number;
|
|
59
|
-
period: number;
|
|
60
|
-
}
|
|
61
56
|
export interface SequenceContext {
|
|
62
57
|
factory: string;
|
|
63
58
|
mainModule: string;
|
|
@@ -67,6 +62,7 @@ export interface SequenceContext {
|
|
|
67
62
|
}
|
|
68
63
|
export interface GasTank {
|
|
69
64
|
id: number;
|
|
65
|
+
chainId: number;
|
|
70
66
|
name: string;
|
|
71
67
|
currentBalance: number;
|
|
72
68
|
unlimited: boolean;
|
|
@@ -86,6 +82,7 @@ export interface GasSponsor {
|
|
|
86
82
|
id: number;
|
|
87
83
|
gasTankId: number;
|
|
88
84
|
projectId: number;
|
|
85
|
+
chainId: number;
|
|
89
86
|
address: string;
|
|
90
87
|
name: string;
|
|
91
88
|
active: boolean;
|
|
@@ -111,6 +108,7 @@ export interface MetaTxn {
|
|
|
111
108
|
}
|
|
112
109
|
export interface MetaTxnLog {
|
|
113
110
|
id: number;
|
|
111
|
+
chainId: number;
|
|
114
112
|
projectId: number;
|
|
115
113
|
txnHash: string;
|
|
116
114
|
txnNonce: string;
|
|
@@ -144,16 +142,6 @@ export interface MetaTxnLog {
|
|
|
144
142
|
updatedAt: string;
|
|
145
143
|
createdAt: string;
|
|
146
144
|
}
|
|
147
|
-
export interface MetaTxnEntry {
|
|
148
|
-
id: number;
|
|
149
|
-
metaTxnID: string;
|
|
150
|
-
txnStatus: ETHTxnStatus;
|
|
151
|
-
txnRevertReason: string;
|
|
152
|
-
index: number;
|
|
153
|
-
logs?: Array<any>;
|
|
154
|
-
updatedAt: string;
|
|
155
|
-
createdAt: string;
|
|
156
|
-
}
|
|
157
145
|
export interface MetaTxnReceipt {
|
|
158
146
|
id: string;
|
|
159
147
|
status: string;
|
|
@@ -247,6 +235,7 @@ export interface Relayer {
|
|
|
247
235
|
feeOptions(args: FeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise<FeeOptionsReturn>;
|
|
248
236
|
getMetaTxnNetworkFeeOptions(args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object, signal?: AbortSignal): Promise<GetMetaTxnNetworkFeeOptionsReturn>;
|
|
249
237
|
getMetaTransactions(args: GetMetaTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<GetMetaTransactionsReturn>;
|
|
238
|
+
getTransactionCost(args: GetTransactionCostArgs, headers?: object, signal?: AbortSignal): Promise<GetTransactionCostReturn>;
|
|
250
239
|
sentTransactions(args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<SentTransactionsReturn>;
|
|
251
240
|
pendingTransactions(args: PendingTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<PendingTransactionsReturn>;
|
|
252
241
|
getGasTank(args: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise<GetGasTankReturn>;
|
|
@@ -263,6 +252,8 @@ export interface Relayer {
|
|
|
263
252
|
adjustGasTankBalance(args: AdjustGasTankBalanceArgs, headers?: object, signal?: AbortSignal): Promise<AdjustGasTankBalanceReturn>;
|
|
264
253
|
getGasTankBalanceAdjustment(args: GetGasTankBalanceAdjustmentArgs, headers?: object, signal?: AbortSignal): Promise<GetGasTankBalanceAdjustmentReturn>;
|
|
265
254
|
listGasTankBalanceAdjustments(args: ListGasTankBalanceAdjustmentsArgs, headers?: object, signal?: AbortSignal): Promise<ListGasTankBalanceAdjustmentsReturn>;
|
|
255
|
+
getProjectBalance(args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetProjectBalanceReturn>;
|
|
256
|
+
adjustProjectBalance(args: AdjustProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise<AdjustProjectBalanceReturn>;
|
|
266
257
|
}
|
|
267
258
|
export interface PingArgs {
|
|
268
259
|
}
|
|
@@ -292,6 +283,7 @@ export interface GetChainIDReturn {
|
|
|
292
283
|
export interface SendMetaTxnArgs {
|
|
293
284
|
call: MetaTxn;
|
|
294
285
|
quote?: string;
|
|
286
|
+
projectID?: number;
|
|
295
287
|
}
|
|
296
288
|
export interface SendMetaTxnReturn {
|
|
297
289
|
status: boolean;
|
|
@@ -351,13 +343,20 @@ export interface GetMetaTxnNetworkFeeOptionsReturn {
|
|
|
351
343
|
}
|
|
352
344
|
export interface GetMetaTransactionsArgs {
|
|
353
345
|
projectId: number;
|
|
354
|
-
gasTankId: number;
|
|
355
346
|
page?: Page;
|
|
356
347
|
}
|
|
357
348
|
export interface GetMetaTransactionsReturn {
|
|
358
349
|
page: Page;
|
|
359
350
|
transactions: Array<MetaTxnLog>;
|
|
360
351
|
}
|
|
352
|
+
export interface GetTransactionCostArgs {
|
|
353
|
+
projectId: number;
|
|
354
|
+
from: string;
|
|
355
|
+
to: string;
|
|
356
|
+
}
|
|
357
|
+
export interface GetTransactionCostReturn {
|
|
358
|
+
cost: number;
|
|
359
|
+
}
|
|
361
360
|
export interface SentTransactionsArgs {
|
|
362
361
|
filter?: SentTransactionsFilter;
|
|
363
362
|
page?: Page;
|
|
@@ -486,6 +485,20 @@ export interface ListGasTankBalanceAdjustmentsReturn {
|
|
|
486
485
|
page: Page;
|
|
487
486
|
adjustments: Array<GasTankBalanceAdjustment>;
|
|
488
487
|
}
|
|
488
|
+
export interface GetProjectBalanceArgs {
|
|
489
|
+
projectId: number;
|
|
490
|
+
}
|
|
491
|
+
export interface GetProjectBalanceReturn {
|
|
492
|
+
balance: number;
|
|
493
|
+
}
|
|
494
|
+
export interface AdjustProjectBalanceArgs {
|
|
495
|
+
projectId: number;
|
|
496
|
+
amount: number;
|
|
497
|
+
identifier: string;
|
|
498
|
+
}
|
|
499
|
+
export interface AdjustProjectBalanceReturn {
|
|
500
|
+
balance: number;
|
|
501
|
+
}
|
|
489
502
|
export declare class Relayer implements Relayer {
|
|
490
503
|
protected hostname: string;
|
|
491
504
|
protected fetch: Fetch;
|
|
@@ -506,6 +519,7 @@ export declare class Relayer implements Relayer {
|
|
|
506
519
|
feeOptions: (args: FeeOptionsArgs, headers?: object, signal?: AbortSignal) => Promise<FeeOptionsReturn>;
|
|
507
520
|
getMetaTxnNetworkFeeOptions: (args: GetMetaTxnNetworkFeeOptionsArgs, headers?: object, signal?: AbortSignal) => Promise<GetMetaTxnNetworkFeeOptionsReturn>;
|
|
508
521
|
getMetaTransactions: (args: GetMetaTransactionsArgs, headers?: object, signal?: AbortSignal) => Promise<GetMetaTransactionsReturn>;
|
|
522
|
+
getTransactionCost: (args: GetTransactionCostArgs, headers?: object, signal?: AbortSignal) => Promise<GetTransactionCostReturn>;
|
|
509
523
|
sentTransactions: (args: SentTransactionsArgs, headers?: object, signal?: AbortSignal) => Promise<SentTransactionsReturn>;
|
|
510
524
|
pendingTransactions: (args: PendingTransactionsArgs, headers?: object, signal?: AbortSignal) => Promise<PendingTransactionsReturn>;
|
|
511
525
|
getGasTank: (args: GetGasTankArgs, headers?: object, signal?: AbortSignal) => Promise<GetGasTankReturn>;
|
|
@@ -522,6 +536,8 @@ export declare class Relayer implements Relayer {
|
|
|
522
536
|
adjustGasTankBalance: (args: AdjustGasTankBalanceArgs, headers?: object, signal?: AbortSignal) => Promise<AdjustGasTankBalanceReturn>;
|
|
523
537
|
getGasTankBalanceAdjustment: (args: GetGasTankBalanceAdjustmentArgs, headers?: object, signal?: AbortSignal) => Promise<GetGasTankBalanceAdjustmentReturn>;
|
|
524
538
|
listGasTankBalanceAdjustments: (args: ListGasTankBalanceAdjustmentsArgs, headers?: object, signal?: AbortSignal) => Promise<ListGasTankBalanceAdjustmentsReturn>;
|
|
539
|
+
getProjectBalance: (args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal) => Promise<GetProjectBalanceReturn>;
|
|
540
|
+
adjustProjectBalance: (args: AdjustProjectBalanceArgs, headers?: object, signal?: AbortSignal) => Promise<AdjustProjectBalanceReturn>;
|
|
525
541
|
}
|
|
526
542
|
export declare class WebrpcError extends Error {
|
|
527
543
|
name: string;
|
|
@@ -576,9 +592,15 @@ export declare class PermissionDeniedError extends WebrpcError {
|
|
|
576
592
|
export declare class MethodNotFoundError extends WebrpcError {
|
|
577
593
|
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
578
594
|
}
|
|
595
|
+
export declare class RequestConflictError extends WebrpcError {
|
|
596
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
597
|
+
}
|
|
579
598
|
export declare class AbortedError extends WebrpcError {
|
|
580
599
|
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
581
600
|
}
|
|
601
|
+
export declare class GeoblockedError extends WebrpcError {
|
|
602
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
603
|
+
}
|
|
582
604
|
export declare class InvalidArgumentError extends WebrpcError {
|
|
583
605
|
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
584
606
|
}
|
|
@@ -591,6 +613,9 @@ export declare class QueryFailedError extends WebrpcError {
|
|
|
591
613
|
export declare class NotFoundError extends WebrpcError {
|
|
592
614
|
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
593
615
|
}
|
|
616
|
+
export declare class InsufficientFeeError extends WebrpcError {
|
|
617
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
618
|
+
}
|
|
594
619
|
export declare enum errors {
|
|
595
620
|
WebrpcEndpoint = "WebrpcEndpoint",
|
|
596
621
|
WebrpcRequestFailed = "WebrpcRequestFailed",
|
|
@@ -606,10 +631,13 @@ export declare enum errors {
|
|
|
606
631
|
Unauthorized = "Unauthorized",
|
|
607
632
|
PermissionDenied = "PermissionDenied",
|
|
608
633
|
MethodNotFound = "MethodNotFound",
|
|
634
|
+
RequestConflict = "RequestConflict",
|
|
609
635
|
Aborted = "Aborted",
|
|
636
|
+
Geoblocked = "Geoblocked",
|
|
610
637
|
InvalidArgument = "InvalidArgument",
|
|
611
638
|
Unavailable = "Unavailable",
|
|
612
639
|
QueryFailed = "QueryFailed",
|
|
613
|
-
NotFound = "NotFound"
|
|
640
|
+
NotFound = "NotFound",
|
|
641
|
+
InsufficientFee = "InsufficientFee"
|
|
614
642
|
}
|
|
615
643
|
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/relayer",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
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",
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
"ethers": ">=6"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@0xsequence/abi": "2.2.
|
|
16
|
-
"@0xsequence/
|
|
17
|
-
"@0xsequence/
|
|
15
|
+
"@0xsequence/abi": "2.2.6",
|
|
16
|
+
"@0xsequence/utils": "2.2.6",
|
|
17
|
+
"@0xsequence/core": "2.2.6"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@0xsequence/wallet-contracts": "^3.0.1",
|
|
21
21
|
"ethers": "6.13.4",
|
|
22
|
-
"@0xsequence/signhub": "2.2.
|
|
23
|
-
"@0xsequence/tests": "2.2.
|
|
22
|
+
"@0xsequence/signhub": "2.2.6",
|
|
23
|
+
"@0xsequence/tests": "2.2.6"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"src",
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,17 @@ export interface Relayer {
|
|
|
54
54
|
delay?: number,
|
|
55
55
|
maxFails?: number
|
|
56
56
|
): Promise<commons.transaction.TransactionResponse>
|
|
57
|
+
|
|
58
|
+
// getMetaTransactions returns a list of meta transactions for a given project and gas tank
|
|
59
|
+
getMetaTransactions(projectId: number, page?: proto.Page): Promise<{
|
|
60
|
+
page: proto.Page,
|
|
61
|
+
transactions: proto.MetaTxnLog[]
|
|
62
|
+
}>
|
|
63
|
+
|
|
64
|
+
// getTransactionCost returns the used fee cost for gas tank during a given period
|
|
65
|
+
getTransactionCost(projectId: number, from: string, to: string): Promise<{
|
|
66
|
+
cost: number
|
|
67
|
+
}>
|
|
57
68
|
}
|
|
58
69
|
|
|
59
70
|
export * from './local-relayer'
|
package/src/local-relayer.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { logger } from '@0xsequence/utils'
|
|
3
|
-
import { FeeOption, FeeQuote, Relayer } from '.'
|
|
3
|
+
import { FeeOption, FeeQuote, proto, Relayer } from '.'
|
|
4
4
|
import { ProviderRelayer, ProviderRelayerOptions } from './provider-relayer'
|
|
5
5
|
import { commons } from '@0xsequence/core'
|
|
6
6
|
|
|
@@ -76,6 +76,19 @@ export class LocalRelayer extends ProviderRelayer implements Relayer {
|
|
|
76
76
|
return responsePromise
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
|
|
80
|
+
async getMetaTransactions(projectId: number, page?: proto.Page): Promise<{
|
|
81
|
+
page: proto.Page,
|
|
82
|
+
transactions: proto.MetaTxnLog[]
|
|
83
|
+
}> {
|
|
84
|
+
return { page: { page: 0, pageSize: 100 }, transactions: [] }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async getTransactionCost(projectId: number, from: string, to: string): Promise<{
|
|
88
|
+
cost: number
|
|
89
|
+
}> {
|
|
90
|
+
return { cost: 0 }
|
|
91
|
+
}
|
|
79
92
|
}
|
|
80
93
|
|
|
81
94
|
function isAbstractSigner(signer: any): signer is ethers.AbstractSigner {
|
package/src/provider-relayer.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { walletContracts } from '@0xsequence/abi'
|
|
3
|
-
import { FeeOption, FeeQuote, Relayer, SimulateResult } from '.'
|
|
3
|
+
import { FeeOption, FeeQuote, proto, Relayer, SimulateResult } from '.'
|
|
4
4
|
import { logger, Optionals } from '@0xsequence/utils'
|
|
5
5
|
import { commons } from '@0xsequence/core'
|
|
6
6
|
|
|
@@ -59,6 +59,15 @@ export abstract class ProviderRelayer implements Relayer {
|
|
|
59
59
|
waitForReceipt?: boolean
|
|
60
60
|
): Promise<commons.transaction.TransactionResponse>
|
|
61
61
|
|
|
62
|
+
abstract getTransactionCost(projectId: number, from: string, to: string): Promise<{
|
|
63
|
+
cost: number
|
|
64
|
+
}>
|
|
65
|
+
|
|
66
|
+
abstract getMetaTransactions(projectId: number, page?: proto.Page): Promise<{
|
|
67
|
+
page: proto.Page,
|
|
68
|
+
transactions: proto.MetaTxnLog[]
|
|
69
|
+
}>
|
|
70
|
+
|
|
62
71
|
async simulate(wallet: string, ...transactions: commons.transaction.Transaction[]): Promise<SimulateResult[]> {
|
|
63
72
|
return (
|
|
64
73
|
await Promise.all(
|
|
@@ -248,6 +257,8 @@ export abstract class ProviderRelayer implements Relayer {
|
|
|
248
257
|
return waitReceipt()
|
|
249
258
|
}
|
|
250
259
|
}
|
|
260
|
+
|
|
261
|
+
|
|
251
262
|
}
|
|
252
263
|
|
|
253
264
|
function isAbstractProvider(provider: any): provider is ethers.AbstractProvider {
|
package/src/rpc-relayer/index.ts
CHANGED
|
@@ -304,6 +304,19 @@ export class RpcRelayer implements Relayer {
|
|
|
304
304
|
wait: async (confirmations?: number) => this.provider!.waitForTransaction(txReceipt.transactionHash, confirmations)
|
|
305
305
|
} as commons.transaction.TransactionResponse
|
|
306
306
|
}
|
|
307
|
+
|
|
308
|
+
async getMetaTransactions(projectId: number, page?: proto.Page): Promise<{
|
|
309
|
+
page: proto.Page,
|
|
310
|
+
transactions: proto.MetaTxnLog[]
|
|
311
|
+
}> {
|
|
312
|
+
return this.service.getMetaTransactions({ projectId, page })
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
async getTransactionCost(projectId: number, from: string, to: string): Promise<{
|
|
316
|
+
cost: number
|
|
317
|
+
}> {
|
|
318
|
+
return this.service.getTransactionCost({ projectId, from, to })
|
|
319
|
+
}
|
|
307
320
|
}
|
|
308
321
|
|
|
309
322
|
class MetaTransactionResponseException {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
// sequence-relayer v0.4.1
|
|
2
|
+
// sequence-relayer v0.4.1 dd95e21fa884c6564199bc3dd5f588534827ffe2
|
|
3
3
|
// --
|
|
4
|
-
// Code generated by webrpc-gen@v0.
|
|
4
|
+
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT.
|
|
5
5
|
//
|
|
6
6
|
// webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ export const WebRPCVersion = 'v1'
|
|
|
12
12
|
export const WebRPCSchemaVersion = 'v0.4.1'
|
|
13
13
|
|
|
14
14
|
// Schema hash generated from your RIDL schema
|
|
15
|
-
export const WebRPCSchemaHash = '
|
|
15
|
+
export const WebRPCSchemaHash = 'dd95e21fa884c6564199bc3dd5f588534827ffe2'
|
|
16
16
|
|
|
17
17
|
//
|
|
18
18
|
// Types
|
|
@@ -62,10 +62,10 @@ export interface RuntimeStatus {
|
|
|
62
62
|
ver: string
|
|
63
63
|
branch: string
|
|
64
64
|
commitHash: string
|
|
65
|
+
chainID: number
|
|
65
66
|
useEIP1559: boolean
|
|
66
67
|
senders: Array<SenderStatus>
|
|
67
68
|
checks: RuntimeChecks
|
|
68
|
-
numTxnsRelayed: NumTxnsRelayed
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export interface SenderStatus {
|
|
@@ -77,12 +77,6 @@ export interface SenderStatus {
|
|
|
77
77
|
|
|
78
78
|
export interface RuntimeChecks {}
|
|
79
79
|
|
|
80
|
-
export interface NumTxnsRelayed {
|
|
81
|
-
prev: number
|
|
82
|
-
current: number
|
|
83
|
-
period: number
|
|
84
|
-
}
|
|
85
|
-
|
|
86
80
|
export interface SequenceContext {
|
|
87
81
|
factory: string
|
|
88
82
|
mainModule: string
|
|
@@ -93,6 +87,7 @@ export interface SequenceContext {
|
|
|
93
87
|
|
|
94
88
|
export interface GasTank {
|
|
95
89
|
id: number
|
|
90
|
+
chainId: number
|
|
96
91
|
name: string
|
|
97
92
|
currentBalance: number
|
|
98
93
|
unlimited: boolean
|
|
@@ -114,6 +109,7 @@ export interface GasSponsor {
|
|
|
114
109
|
id: number
|
|
115
110
|
gasTankId: number
|
|
116
111
|
projectId: number
|
|
112
|
+
chainId: number
|
|
117
113
|
address: string
|
|
118
114
|
name: string
|
|
119
115
|
active: boolean
|
|
@@ -142,6 +138,7 @@ export interface MetaTxn {
|
|
|
142
138
|
|
|
143
139
|
export interface MetaTxnLog {
|
|
144
140
|
id: number
|
|
141
|
+
chainId: number
|
|
145
142
|
projectId: number
|
|
146
143
|
txnHash: string
|
|
147
144
|
txnNonce: string
|
|
@@ -172,17 +169,6 @@ export interface MetaTxnLog {
|
|
|
172
169
|
createdAt: string
|
|
173
170
|
}
|
|
174
171
|
|
|
175
|
-
export interface MetaTxnEntry {
|
|
176
|
-
id: number
|
|
177
|
-
metaTxnID: string
|
|
178
|
-
txnStatus: ETHTxnStatus
|
|
179
|
-
txnRevertReason: string
|
|
180
|
-
index: number
|
|
181
|
-
logs?: Array<any>
|
|
182
|
-
updatedAt: string
|
|
183
|
-
createdAt: string
|
|
184
|
-
}
|
|
185
|
-
|
|
186
172
|
export interface MetaTxnReceipt {
|
|
187
173
|
id: string
|
|
188
174
|
status: string
|
|
@@ -293,6 +279,7 @@ export interface Relayer {
|
|
|
293
279
|
signal?: AbortSignal
|
|
294
280
|
): Promise<GetMetaTxnNetworkFeeOptionsReturn>
|
|
295
281
|
getMetaTransactions(args: GetMetaTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<GetMetaTransactionsReturn>
|
|
282
|
+
getTransactionCost(args: GetTransactionCostArgs, headers?: object, signal?: AbortSignal): Promise<GetTransactionCostReturn>
|
|
296
283
|
sentTransactions(args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<SentTransactionsReturn>
|
|
297
284
|
pendingTransactions(args: PendingTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<PendingTransactionsReturn>
|
|
298
285
|
getGasTank(args: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise<GetGasTankReturn>
|
|
@@ -329,6 +316,12 @@ export interface Relayer {
|
|
|
329
316
|
headers?: object,
|
|
330
317
|
signal?: AbortSignal
|
|
331
318
|
): Promise<ListGasTankBalanceAdjustmentsReturn>
|
|
319
|
+
getProjectBalance(args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetProjectBalanceReturn>
|
|
320
|
+
adjustProjectBalance(
|
|
321
|
+
args: AdjustProjectBalanceArgs,
|
|
322
|
+
headers?: object,
|
|
323
|
+
signal?: AbortSignal
|
|
324
|
+
): Promise<AdjustProjectBalanceReturn>
|
|
332
325
|
}
|
|
333
326
|
|
|
334
327
|
export interface PingArgs {}
|
|
@@ -359,6 +352,7 @@ export interface GetChainIDReturn {
|
|
|
359
352
|
export interface SendMetaTxnArgs {
|
|
360
353
|
call: MetaTxn
|
|
361
354
|
quote?: string
|
|
355
|
+
projectID?: number
|
|
362
356
|
}
|
|
363
357
|
|
|
364
358
|
export interface SendMetaTxnReturn {
|
|
@@ -425,7 +419,6 @@ export interface GetMetaTxnNetworkFeeOptionsReturn {
|
|
|
425
419
|
}
|
|
426
420
|
export interface GetMetaTransactionsArgs {
|
|
427
421
|
projectId: number
|
|
428
|
-
gasTankId: number
|
|
429
422
|
page?: Page
|
|
430
423
|
}
|
|
431
424
|
|
|
@@ -433,6 +426,15 @@ export interface GetMetaTransactionsReturn {
|
|
|
433
426
|
page: Page
|
|
434
427
|
transactions: Array<MetaTxnLog>
|
|
435
428
|
}
|
|
429
|
+
export interface GetTransactionCostArgs {
|
|
430
|
+
projectId: number
|
|
431
|
+
from: string
|
|
432
|
+
to: string
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export interface GetTransactionCostReturn {
|
|
436
|
+
cost: number
|
|
437
|
+
}
|
|
436
438
|
export interface SentTransactionsArgs {
|
|
437
439
|
filter?: SentTransactionsFilter
|
|
438
440
|
page?: Page
|
|
@@ -577,6 +579,22 @@ export interface ListGasTankBalanceAdjustmentsReturn {
|
|
|
577
579
|
page: Page
|
|
578
580
|
adjustments: Array<GasTankBalanceAdjustment>
|
|
579
581
|
}
|
|
582
|
+
export interface GetProjectBalanceArgs {
|
|
583
|
+
projectId: number
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export interface GetProjectBalanceReturn {
|
|
587
|
+
balance: number
|
|
588
|
+
}
|
|
589
|
+
export interface AdjustProjectBalanceArgs {
|
|
590
|
+
projectId: number
|
|
591
|
+
amount: number
|
|
592
|
+
identifier: string
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export interface AdjustProjectBalanceReturn {
|
|
596
|
+
balance: number
|
|
597
|
+
}
|
|
580
598
|
|
|
581
599
|
//
|
|
582
600
|
// Client
|
|
@@ -587,7 +605,7 @@ export class Relayer implements Relayer {
|
|
|
587
605
|
protected path = '/rpc/Relayer/'
|
|
588
606
|
|
|
589
607
|
constructor(hostname: string, fetch: Fetch) {
|
|
590
|
-
this.hostname = hostname
|
|
608
|
+
this.hostname = hostname.replace(/\/*$/, '')
|
|
591
609
|
this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
|
|
592
610
|
}
|
|
593
611
|
|
|
@@ -822,6 +840,25 @@ export class Relayer implements Relayer {
|
|
|
822
840
|
)
|
|
823
841
|
}
|
|
824
842
|
|
|
843
|
+
getTransactionCost = (
|
|
844
|
+
args: GetTransactionCostArgs,
|
|
845
|
+
headers?: object,
|
|
846
|
+
signal?: AbortSignal
|
|
847
|
+
): Promise<GetTransactionCostReturn> => {
|
|
848
|
+
return this.fetch(this.url('GetTransactionCost'), createHTTPRequest(args, headers, signal)).then(
|
|
849
|
+
res => {
|
|
850
|
+
return buildResponse(res).then(_data => {
|
|
851
|
+
return {
|
|
852
|
+
cost: <number>_data.cost
|
|
853
|
+
}
|
|
854
|
+
})
|
|
855
|
+
},
|
|
856
|
+
error => {
|
|
857
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
858
|
+
}
|
|
859
|
+
)
|
|
860
|
+
}
|
|
861
|
+
|
|
825
862
|
sentTransactions = (args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise<SentTransactionsReturn> => {
|
|
826
863
|
return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers, signal)).then(
|
|
827
864
|
res => {
|
|
@@ -1099,6 +1136,40 @@ export class Relayer implements Relayer {
|
|
|
1099
1136
|
}
|
|
1100
1137
|
)
|
|
1101
1138
|
}
|
|
1139
|
+
|
|
1140
|
+
getProjectBalance = (args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise<GetProjectBalanceReturn> => {
|
|
1141
|
+
return this.fetch(this.url('GetProjectBalance'), createHTTPRequest(args, headers, signal)).then(
|
|
1142
|
+
res => {
|
|
1143
|
+
return buildResponse(res).then(_data => {
|
|
1144
|
+
return {
|
|
1145
|
+
balance: <number>_data.balance
|
|
1146
|
+
}
|
|
1147
|
+
})
|
|
1148
|
+
},
|
|
1149
|
+
error => {
|
|
1150
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1151
|
+
}
|
|
1152
|
+
)
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
adjustProjectBalance = (
|
|
1156
|
+
args: AdjustProjectBalanceArgs,
|
|
1157
|
+
headers?: object,
|
|
1158
|
+
signal?: AbortSignal
|
|
1159
|
+
): Promise<AdjustProjectBalanceReturn> => {
|
|
1160
|
+
return this.fetch(this.url('AdjustProjectBalance'), createHTTPRequest(args, headers, signal)).then(
|
|
1161
|
+
res => {
|
|
1162
|
+
return buildResponse(res).then(_data => {
|
|
1163
|
+
return {
|
|
1164
|
+
balance: <number>_data.balance
|
|
1165
|
+
}
|
|
1166
|
+
})
|
|
1167
|
+
},
|
|
1168
|
+
error => {
|
|
1169
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
|
|
1170
|
+
}
|
|
1171
|
+
)
|
|
1172
|
+
}
|
|
1102
1173
|
}
|
|
1103
1174
|
|
|
1104
1175
|
const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => {
|
|
@@ -1349,6 +1420,19 @@ export class MethodNotFoundError extends WebrpcError {
|
|
|
1349
1420
|
}
|
|
1350
1421
|
}
|
|
1351
1422
|
|
|
1423
|
+
export class RequestConflictError extends WebrpcError {
|
|
1424
|
+
constructor(
|
|
1425
|
+
name: string = 'RequestConflict',
|
|
1426
|
+
code: number = 1004,
|
|
1427
|
+
message: string = 'Conflict with target resource',
|
|
1428
|
+
status: number = 0,
|
|
1429
|
+
cause?: string
|
|
1430
|
+
) {
|
|
1431
|
+
super(name, code, message, status, cause)
|
|
1432
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype)
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1352
1436
|
export class AbortedError extends WebrpcError {
|
|
1353
1437
|
constructor(
|
|
1354
1438
|
name: string = 'Aborted',
|
|
@@ -1362,6 +1446,19 @@ export class AbortedError extends WebrpcError {
|
|
|
1362
1446
|
}
|
|
1363
1447
|
}
|
|
1364
1448
|
|
|
1449
|
+
export class GeoblockedError extends WebrpcError {
|
|
1450
|
+
constructor(
|
|
1451
|
+
name: string = 'Geoblocked',
|
|
1452
|
+
code: number = 1006,
|
|
1453
|
+
message: string = 'Geoblocked region',
|
|
1454
|
+
status: number = 0,
|
|
1455
|
+
cause?: string
|
|
1456
|
+
) {
|
|
1457
|
+
super(name, code, message, status, cause)
|
|
1458
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype)
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1365
1462
|
export class InvalidArgumentError extends WebrpcError {
|
|
1366
1463
|
constructor(
|
|
1367
1464
|
name: string = 'InvalidArgument',
|
|
@@ -1414,6 +1511,19 @@ export class NotFoundError extends WebrpcError {
|
|
|
1414
1511
|
}
|
|
1415
1512
|
}
|
|
1416
1513
|
|
|
1514
|
+
export class InsufficientFeeError extends WebrpcError {
|
|
1515
|
+
constructor(
|
|
1516
|
+
name: string = 'InsufficientFee',
|
|
1517
|
+
code: number = 3004,
|
|
1518
|
+
message: string = 'Insufficient fee',
|
|
1519
|
+
status: number = 0,
|
|
1520
|
+
cause?: string
|
|
1521
|
+
) {
|
|
1522
|
+
super(name, code, message, status, cause)
|
|
1523
|
+
Object.setPrototypeOf(this, InsufficientFeeError.prototype)
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1417
1527
|
export enum errors {
|
|
1418
1528
|
WebrpcEndpoint = 'WebrpcEndpoint',
|
|
1419
1529
|
WebrpcRequestFailed = 'WebrpcRequestFailed',
|
|
@@ -1429,11 +1539,14 @@ export enum errors {
|
|
|
1429
1539
|
Unauthorized = 'Unauthorized',
|
|
1430
1540
|
PermissionDenied = 'PermissionDenied',
|
|
1431
1541
|
MethodNotFound = 'MethodNotFound',
|
|
1542
|
+
RequestConflict = 'RequestConflict',
|
|
1432
1543
|
Aborted = 'Aborted',
|
|
1544
|
+
Geoblocked = 'Geoblocked',
|
|
1433
1545
|
InvalidArgument = 'InvalidArgument',
|
|
1434
1546
|
Unavailable = 'Unavailable',
|
|
1435
1547
|
QueryFailed = 'QueryFailed',
|
|
1436
|
-
NotFound = 'NotFound'
|
|
1548
|
+
NotFound = 'NotFound',
|
|
1549
|
+
InsufficientFee = 'InsufficientFee'
|
|
1437
1550
|
}
|
|
1438
1551
|
|
|
1439
1552
|
const webrpcErrorByCode: { [code: number]: any } = {
|
|
@@ -1451,11 +1564,14 @@ const webrpcErrorByCode: { [code: number]: any } = {
|
|
|
1451
1564
|
[1000]: UnauthorizedError,
|
|
1452
1565
|
[1001]: PermissionDeniedError,
|
|
1453
1566
|
[1003]: MethodNotFoundError,
|
|
1567
|
+
[1004]: RequestConflictError,
|
|
1454
1568
|
[1005]: AbortedError,
|
|
1569
|
+
[1006]: GeoblockedError,
|
|
1455
1570
|
[2001]: InvalidArgumentError,
|
|
1456
1571
|
[2002]: UnavailableError,
|
|
1457
1572
|
[2003]: QueryFailedError,
|
|
1458
|
-
[3000]: NotFoundError
|
|
1573
|
+
[3000]: NotFoundError,
|
|
1574
|
+
[3004]: InsufficientFeeError
|
|
1459
1575
|
}
|
|
1460
1576
|
|
|
1461
1577
|
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>
|