-
Notifications
You must be signed in to change notification settings - Fork 5
/
utils.js
1102 lines (999 loc) · 26.7 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import fetch from 'isomorphic-fetch';
import CoreError, { RequestError, ErrorCodes } from '~/common/error';
import TransactionQueue from '~/common/queue';
import checkAccount from '~/common/checkAccount';
import checkOptions from '~/common/checkOptions';
import loop from '~/common/loop';
import parameterize from '~/common/parameterize';
import { CALL_OP, ZERO_ADDRESS } from '~/common/constants';
import { formatTypedData, signTypedData } from '~/common/typedData';
import { getTokenContract, getSafeContract } from '~/common/getContracts';
/** @access private */
const transactionQueue = new TransactionQueue();
async function request(endpoint, userOptions) {
const options = checkOptions(userOptions, {
path: {
type: 'array',
},
method: {
type: 'string',
default: 'GET',
},
data: {
type: 'object',
default: {},
},
isTrailingSlash: {
type: 'boolean',
default: true,
},
});
const { path, method, data } = options;
const request = {
method,
};
let paramsStr = '';
if (data) {
if (options.method === 'GET') {
paramsStr = parameterize(data);
} else if (typeof window !== 'undefined' && data instanceof FormData) {
request.body = data;
} else {
request.body = JSON.stringify(data);
request.headers = {
'Content-Type': 'application/json',
};
}
}
const slash = options.isTrailingSlash ? '/' : '';
const url = `${endpoint}/${path.join('/')}${slash}${paramsStr}`;
try {
return fetch(url, request).then((response) => {
const contentType = response.headers.get('Content-Type');
if (contentType && contentType.includes('application/json')) {
return response.json().then((json) => {
if (response.status >= 400) {
throw new RequestError(url, json, response.status);
}
return json;
});
} else {
if (response.status >= 400) {
throw new RequestError(url, response.body, response.status);
}
return response.body;
}
});
} catch (err) {
throw new RequestError(url, err.message);
}
}
async function requestRelayer(endpoint, userOptions) {
const options = checkOptions(userOptions, {
path: {
type: 'array',
},
version: {
type: 'number',
default: 1,
},
method: {
type: 'string',
default: 'GET',
},
data: {
type: 'object',
default: {},
},
});
const { path, method, data, version } = options;
return request(endpoint, {
path: ['api', `v${version}`].concat(path),
method,
data,
});
}
async function requestGraph(endpoint, subgraphName, userOptions) {
const options = checkOptions(userOptions, {
query: {
type: 'string',
},
variables: {
type: 'object',
default: {},
},
});
const query = options.query.replace(/\s\s+/g, ' ');
const variables =
Object.keys(options.variables).length === 0 ? undefined : options.variables;
const response = await request(endpoint, {
path: ['subgraphs', 'name', subgraphName],
method: 'POST',
data: {
query,
variables,
},
isTrailingSlash: false,
});
return response.data;
}
async function requestIndexedDB(
graphNodeEndpoint,
subgraphName,
databaseSource,
data,
parameters,
) {
let response;
switch (data) {
case 'activity_stream':
response = getNotificationsStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
parameters,
);
break;
case 'organization_status':
response = getOrganizationStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
parameters,
);
break;
case 'safe_addresses':
response = getSafeAddresses(
graphNodeEndpoint,
subgraphName,
databaseSource,
parameters,
);
break;
case 'balances':
response = getBalancesStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
parameters,
);
break;
case 'trust_network':
response = getTrustNetworkStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
parameters,
);
break;
case 'trust_limits':
response = getTrustLimitsStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
parameters,
);
break;
}
return response;
}
function getNotificationsStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
parameters,
) {
let query;
switch (databaseSource) {
case 'graph':
default:
query = {
query: `{
notifications(${parameters}) {
id
transactionHash
safeAddress
type
time
trust {
user
canSendTo
limitPercentage
}
transfer {
from
to
amount
}
hubTransfer {
from
to
amount
}
ownership {
adds
removes
}
}
}`,
};
break;
}
return requestGraph(graphNodeEndpoint, subgraphName, query);
}
function getOrganizationStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
ownerAddress,
) {
let query;
switch (databaseSource) {
case 'graph':
default:
query = {
query: `{
user(id: "${ownerAddress.toLowerCase()}") {
id,
safes {
id
organization
}
}
}`,
};
break;
}
return requestGraph(graphNodeEndpoint, subgraphName, query);
}
function getSafeAddresses(
graphNodeEndpoint,
subgraphName,
databaseSource,
parameters,
) {
let query;
switch (databaseSource) {
case 'graph':
default:
query = {
query: `{
user(id: "${parameters.ownerAddress.toLowerCase()}") {
safeAddresses,
}
}`,
};
break;
}
return requestGraph(graphNodeEndpoint, subgraphName, query);
}
function getBalancesStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
safeAddress,
) {
let query;
switch (databaseSource) {
case 'graph':
default:
query = {
query: `{
safe(id: "${safeAddress.toLowerCase()}") {
balances {
token {
id
}
amount
}
}
}`,
};
break;
}
return requestGraph(graphNodeEndpoint, subgraphName, query);
}
function getTrustNetworkStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
safeAddress,
) {
let query;
switch (databaseSource) {
case 'graph':
default:
query = {
query: `{
trusts(where: { userAddress: "${safeAddress}" }) {
id
limitPercentage
}
}`,
};
break;
}
return requestGraph(graphNodeEndpoint, subgraphName, query);
}
function getTrustLimitsStatus(
graphNodeEndpoint,
subgraphName,
databaseSource,
safeAddress,
) {
let query;
switch (databaseSource) {
case 'graph':
default:
query = {
query: `{
safe(id: "${safeAddress}") {
outgoing {
limitPercentage
userAddress
canSendToAddress
}
incoming {
limitPercentage
userAddress
user {
outgoing {
canSendToAddress
limitPercentage
}
}
canSendToAddress
}
}
}`,
};
break;
}
return requestGraph(graphNodeEndpoint, subgraphName, query);
}
async function estimateTransactionCosts(
endpoint,
{
safeAddress,
to,
txData,
value = 0,
gasToken = ZERO_ADDRESS,
operation = CALL_OP,
},
) {
return await requestRelayer(endpoint, {
path: ['safes', safeAddress, 'transactions', 'estimate'],
method: 'POST',
version: 2,
data: {
safe: safeAddress,
data: txData,
to,
value,
operation,
gasToken,
},
});
}
/**
* Manages transaction queue to finalize currently running tasks and starts the
* next one when ready.
*
* @access private
*
* @param {Web3} web3 - Web3 instance
* @param {string} endpoint - URL of relayer Service
* @param {string} safeAddress - address of Safe
* @param {number} pendingTicketId - id of the task
*/
async function waitForPendingTransactions(
web3,
endpoint,
safeAddress,
pendingTicketId,
) {
await loop(
async () => {
// Check if transaction is ready and leave loop if yes
if (!transactionQueue.isLocked(safeAddress)) {
return transactionQueue.isNextInQueue(safeAddress, pendingTicketId);
}
// .. otherwise check what task is currently running
const {
txHash,
nonce,
ticketId: currentTicketId,
} = transactionQueue.getCurrentTransaction(safeAddress);
// Ask relayer if it finished
try {
const response = await requestRelayer(endpoint, {
path: ['safes', safeAddress, 'transactions'],
method: 'GET',
version: 1,
data: {
limit: 1,
ethereum_tx__tx_hash: txHash,
nonce,
},
});
// ... and unqueue the task in case it did!
if (response.results.length === 1) {
transactionQueue.unlockTransaction(safeAddress, currentTicketId);
transactionQueue.unqueue(safeAddress, currentTicketId);
}
} catch {
// Do nothing
}
return false;
},
(isReady) => {
return isReady;
},
);
}
/**
* Retreive an nonce and make sure it does not collide with currently
* pending transactions already using it.
*
* @access private
*
* @param {Web3} web3 - Web3 instance
* @param {string} endpoint - URL of Relayer Service
* @param {string} safeAddress - address of Safe
*/
async function requestNonce(web3, endpoint, safeAddress) {
let nonce = null;
try {
const response = await requestRelayer(endpoint, {
path: ['safes', safeAddress],
method: 'GET',
version: 1,
data: {
limit: 1,
},
});
nonce = response.nonce || null;
} catch (err) {
// Do nothing!
}
// Fallback to retreive nonce from Safe contract method (already incremented)
if (nonce === null) {
return await getSafeContract(web3, safeAddress).methods.nonce().call();
}
return `${parseInt(nonce, 10)}`;
}
/**
* Utils submodule for common transaction and relayer methods.
*
* @access private
*
* @param {Web3} web3 - Web3 instance
* @param {Object} contracts - common contract instances
* @param {Object} globalOptions - global core options
*
* @return {Object} - utils module instance
*/
export default function createUtilsModule(web3, contracts, globalOptions) {
const {
apiServiceEndpoint,
databaseSource,
graphNodeEndpoint,
relayServiceEndpoint,
subgraphName,
} = globalOptions;
const { hub } = contracts;
// Get a list of all Circles Token owned by this address to find out with
// which we can pay this transaction
async function listAllTokens(safeAddress) {
const tokens = [];
// Fetch token balance directly from Ethereum node to start with
const tokenAddress = await hub.methods.userToToken(safeAddress).call();
if (tokenAddress !== ZERO_ADDRESS) {
const tokenContract = getTokenContract(web3, tokenAddress);
const amount = await tokenContract.methods.balanceOf(safeAddress).call();
tokens.push({
amount: web3.utils.toBN(amount.toString()),
address: web3.utils.toChecksumAddress(tokenAddress),
ownerAddress: safeAddress,
});
}
// Additionally get all other tokens from the Graph
try {
const tokensResponse = await requestGraph(
graphNodeEndpoint,
subgraphName,
{
query: `{
safe(id: "${safeAddress.toLowerCase()}") {
balances {
token {
id
owner {
id
}
}
amount
}
}
}`,
},
);
if (tokensResponse && tokensResponse.safe) {
tokensResponse.safe.balances.forEach((balance) => {
const tokenAddress = web3.utils.toChecksumAddress(balance.token.id);
const ownerAddress = web3.utils.toChecksumAddress(
balance.token.owner.id,
);
if (tokens.find(({ address }) => address === tokenAddress)) {
return;
}
tokens.push({
amount: web3.utils.toBN(balance.amount),
address: tokenAddress,
ownerAddress,
});
});
}
} catch {
// Do nothing ..
}
return tokens.sort(({ amount: amountA }, { amount: amountB }) => {
return web3.utils.toBN(amountA).cmp(web3.utils.toBN(amountB));
});
}
return {
/**
* Detect an Ethereum address in any string.
*
* @namespace core.utils.matchAddress
*
* @param {string} str - string
*
* @return {string} - Ethereum address or null
*/
matchAddress: (str) => {
const results = str.match(/0x[a-fA-F0-9]{40}/);
if (results && results.length > 0) {
return results[0];
} else {
return null;
}
},
/**
* Convert to fractional monetary unit of Circles
* named Freckles.
*
* @namespace core.utils.toFreckles
*
* @param {string|number} value - value in Circles
*
* @return {string} - value in Freckles
*/
toFreckles: (value) => {
return web3.utils.toWei(`${value}`, 'ether');
},
/**
* Convert from Freckles to Circles number.
*
* @namespace core.utils.fromFreckles
*
* @param {string|number} value - value in Freckles
*
* @return {number} - value in Circles
*/
fromFreckles: (value) => {
return parseInt(web3.utils.fromWei(`${value}`, 'ether'), 10);
},
/**
* Send an API request to the Gnosis Relayer.
*
* @namespace core.utils.requestRelayer
*
* @param {Object} userOptions - request options
* @param {string[]} userOptions.path - API path as array
* @param {number} userOptions.version - API version 1 or 2
* @param {string} userOptions.method - API request method (GET, POST)
* @param {Object} userOptions.data - data payload
*/
requestRelayer: async (userOptions) => {
return requestRelayer(relayServiceEndpoint, userOptions);
},
/**
* Query the Graph Node with GraphQL.
*
* @namespace core.utils.requestGraph
*
* @param {Object} userOptions - query options
* @param {string} userOptions.query - GraphQL query
* @param {Object} userOptions.variables - GraphQL variables
*/
requestGraph: async (userOptions) => {
return requestGraph(graphNodeEndpoint, subgraphName, userOptions);
},
/**
* Query the Graph Node or Land Graph Node with GraphQL.
*
* @namespace core.utils.requestIndexedDB
*
* @param {string} data - data to obtain
* @param {Object} parameters - parameters needed for query
*/
requestIndexedDB: async (data, parameters) => {
return requestIndexedDB(
graphNodeEndpoint,
subgraphName,
databaseSource,
data,
parameters,
);
},
/**
* Get a list of all tokens and their current balance a user owns. This can
* be used to find the right token for a transaction.
*
* @namespace core.utils.listAllTokens
*
* @param {Object} userOptions - query options
* @param {string} userOptions.safeAddress - address of Safe
*
* @return {Array} - List of tokens with current balance and address
*/
listAllTokens: async (userOptions) => {
const options = checkOptions(userOptions, {
safeAddress: {
type: web3.utils.checkAddressChecksum,
},
});
return await listAllTokens(options.safeAddress);
},
/**
* Send Transaction to Relayer and pay with Circles Token.
*
* @namespace core.utils.executeTokenSafeTx
*
* @param {Object} account - web3 account instance
* @param {Object} userOptions - query options
* @param {string} userOptions.safeAddress - address of Safe
* @param {Object} userOptions.txData - encoded transaction data
*
* @return {string} - transaction hash
*/
executeTokenSafeTx: async (account, userOptions) => {
checkAccount(web3, account);
const options = checkOptions(userOptions, {
safeAddress: {
type: web3.utils.checkAddressChecksum,
},
to: {
type: web3.utils.checkAddressChecksum,
},
txData: {
type: web3.utils.isHexStrict,
},
});
const { txData, safeAddress, to } = options;
const operation = CALL_OP;
const refundReceiver = ZERO_ADDRESS;
const value = 0;
// Estimate gas costs and find out if we have a token with enough balance
// to pay them. We use the ZERO_ADDRESS as a gasToken for now as we
// didn't select the actual Circles Token yet to pay the transaction for
// the relayer
const preEstimation = await estimateTransactionCosts(
relayServiceEndpoint,
{
gasToken: ZERO_ADDRESS,
operation,
safeAddress,
to,
txData,
value,
},
);
const totalGasEstimate = web3.utils
.toBN(preEstimation.dataGas)
.add(new web3.utils.BN(preEstimation.safeTxGas))
.mul(new web3.utils.BN(preEstimation.gasPrice));
const tokens = await listAllTokens(safeAddress);
if (tokens.length === 0) {
throw new CoreError(
'No tokens given to pay transaction',
ErrorCodes.INSUFFICIENT_FUNDS,
);
}
const foundToken = tokens.find(({ amount }) => {
return web3.utils.toBN(amount).gte(totalGasEstimate);
});
if (!foundToken) {
throw new CoreError(
'No token found with sufficient funds to pay transaction',
ErrorCodes.INSUFFICIENT_FUNDS,
);
}
// Estimate the costs again, this time with the actual token we will use
// in the Relayer. This is a little bit cumbersome, but the relayer will
// throw an exception otherwise, as gas estimations might diverge a
// little when using different tokens
const { dataGas, safeTxGas, gasPrice } = await estimateTransactionCosts(
relayServiceEndpoint,
{
gasToken: foundToken.address,
operation,
safeAddress,
to,
txData,
value,
},
);
const gasToken = foundToken.address;
// Register transaction in waiting queue
const ticketId = transactionQueue.queue(safeAddress);
// Wait until transaction can be executed
await waitForPendingTransactions(
web3,
relayServiceEndpoint,
safeAddress,
ticketId,
);
// Request nonce for Safe
const nonce = await requestNonce(web3, relayServiceEndpoint, safeAddress);
// Prepare EIP712 transaction data and sign it
const typedData = formatTypedData(
to,
value,
txData,
operation,
safeTxGas,
dataGas,
gasPrice,
gasToken,
refundReceiver,
nonce,
safeAddress,
);
const signature = signTypedData(web3, account.privateKey, typedData);
// Send transaction to relayer
try {
const { txHash } = await requestRelayer(relayServiceEndpoint, {
path: ['safes', safeAddress, 'transactions'],
method: 'POST',
version: 1,
data: {
to,
value,
data: txData,
operation,
signatures: [signature],
safeTxGas,
dataGas,
gasPrice,
nonce,
gasToken,
},
});
// Register transaction so we can check later if it finished
transactionQueue.lockTransaction(safeAddress, {
nonce,
ticketId,
txHash,
});
return txHash;
} catch {
transactionQueue.unlockTransaction(safeAddress, ticketId);
transactionQueue.unqueue(safeAddress, ticketId);
return null;
}
},
/**
* Send a transaction to the relayer which will be executed by it.
* The gas costs will be estimated by the relayer before.
*
* @namespace core.utils.executeSafeTx
*
* @param {Object} account - web3 account instance
* @param {Object} userOptions - query options
* @param {string} userOptions.safeAddress - address of Safe
* @param {string} userOptions.to - forwarded address (from is the relayer)
* @param {string} userOptions.gasToken - address of ERC20 token
* @param {Object} userOptions.txData - encoded transaction data
* @param {number} userOptions.value - value in Wei
*
* @return {string} - transaction hash
*/
executeSafeTx: async (account, userOptions) => {
checkAccount(web3, account);
const options = checkOptions(userOptions, {
safeAddress: {
type: web3.utils.checkAddressChecksum,
},
to: {
type: web3.utils.checkAddressChecksum,
},
gasToken: {
type: web3.utils.checkAddressChecksum,
default: ZERO_ADDRESS,
},
txData: {
type: web3.utils.isHexStrict,
default: '0x',
},
value: {
type: 'number',
default: 0,
},
});
const { to, gasToken, txData, value, safeAddress } = options;
const operation = CALL_OP;
const refundReceiver = ZERO_ADDRESS;
const { dataGas, gasPrice, safeTxGas } = await estimateTransactionCosts(
relayServiceEndpoint,
{
gasToken,
operation,
safeAddress,
to,
txData,
value,
},
);
// Register transaction in waiting queue
const ticketId = transactionQueue.queue(safeAddress);
// Wait until Relayer allocates enough funds to pay for transaction
const totalGasEstimate = web3.utils
.toBN(dataGas)
.add(new web3.utils.BN(safeTxGas))
.mul(new web3.utils.BN(gasPrice));
await loop(
() => {
return web3.eth.getBalance(safeAddress);
},
(balance) => {
return web3.utils.toBN(balance).gte(totalGasEstimate);
},
);
// Wait until transaction can be executed
await waitForPendingTransactions(
web3,
relayServiceEndpoint,
safeAddress,
ticketId,
);
// Request nonce for Safe
const nonce = await requestNonce(web3, relayServiceEndpoint, safeAddress);
// Prepare EIP712 transaction data and sign it
const typedData = formatTypedData(
to,
value,
txData,
operation,
safeTxGas,
dataGas,
gasPrice,
gasToken,
refundReceiver,
nonce,
safeAddress,
);
const signature = signTypedData(web3, account.privateKey, typedData);
// Send transaction to relayer
try {
const { txHash } = await requestRelayer(relayServiceEndpoint, {
path: ['safes', safeAddress, 'transactions'],
method: 'POST',
version: 1,
data: {
to,
value,
data: txData,
operation,
signatures: [signature],
safeTxGas,
dataGas,
gasPrice,
nonce,
gasToken,
},
});
// Register transaction so we can check later if it finished
transactionQueue.lockTransaction(safeAddress, {
nonce,
ticketId,
txHash,
});
return txHash;
} catch {