@@ -37,6 +37,7 @@ type SeiExplorerAccountTransactionsResponse = {
37
37
export class SeiExplorerWatcher extends CosmwasmWatcher {
38
38
explorerGraphql : string ;
39
39
explorerTxs : string ;
40
+ accountId : number ;
40
41
41
42
constructor ( network : Environment ) {
42
43
super ( network , 'sei' ) ;
@@ -54,30 +55,45 @@ export class SeiExplorerWatcher extends CosmwasmWatcher {
54
55
: network === 'testnet'
55
56
? SEI_EXPLORER_TXS_TESTNET
56
57
: '' ;
58
+ this . accountId = network === 'mainnet' ? 42 : network === 'testnet' ? 3254150 : 0 ;
59
+ // 42 is the account id of sei1gjrrme22cyha4ht2xapn3f08zzw6z3d4uxx6fyy9zd5dyr3yxgzqqncdqn <-- mainnet
60
+ // MAINNET:
61
+ // curl https://pacific-1-graphql.alleslabs.dev/v1/graphql \
62
+ // -X POST \
63
+ // -H "Content-Type: application/json" \
64
+ // --data '{"query":"query getAccountIdByAddressQueryDocument($address: String!) {accounts_by_pk(address: $address) {id}}", "variables":{"address":"sei1gjrrme22cyha4ht2xapn3f08zzw6z3d4uxx6fyy9zd5dyr3yxgzqqncdqn"}, "operationName":"getAccountIdByAddressQueryDocument" }'
65
+ // {"data":{"accounts_by_pk":{"id":42}}}
66
+ //
67
+ // 3254150 is the account number of sei1nna9mzp274djrgzhzkac2gvm3j27l402s4xzr08chq57pjsupqnqaj0d5s <-- testnet
68
+ // TESTNET:
69
+ // curl https://atlantic-2-graphql.alleslabs.dev/v1/graphql \
70
+ // -X POST \
71
+ // -H "Content-Type: application/json" \
72
+ // --data '{"query":"query getAccountIdByAddressQueryDocument($address: String!) {accounts_by_pk(address: $address) {id}}", "variables":{"address":"sei1nna9mzp274djrgzhzkac2gvm3j27l402s4xzr08chq57pjsupqnqaj0d5s"}, "operationName":"getAccountIdByAddressQueryDocument" }'
73
+ // {"data":{"accounts_by_pk":{"id":3254150}}}
74
+ // returned by getAccountIdByAddressQueryDocument
57
75
}
58
76
59
77
makeGraphQLQuery ( offset : number , pageSize : number ) {
60
78
return {
61
79
query :
62
80
'query getTxsByAddressPagination($expression: account_transactions_bool_exp, $offset: Int!, $pageSize: Int!) {\n account_transactions(\n where: $expression\n order_by: {block_height: desc}\n offset: $offset\n limit: $pageSize\n ) {\n block {\n height\n timestamp\n }\n transaction {\n account {\n address\n }\n hash\n success\n messages\n is_clear_admin\n is_execute\n is_ibc\n is_instantiate\n is_migrate\n is_send\n is_store_code\n is_update_admin\n }\n is_signer\n }\n}' ,
63
- variables : { expression : { account_id : { _eq : 42 } } , offset, pageSize } ,
64
- // TODO: change this to allow for testnet
65
- // 42 is the account id of sei1gjrrme22cyha4ht2xapn3f08zzw6z3d4uxx6fyy9zd5dyr3yxgzqqncdqn
66
- // returned by getAccountIdByAddressQueryDocument
81
+ variables : { expression : { account_id : { _eq : this . accountId } } , offset, pageSize } ,
67
82
operationName : 'getTxsByAddressPagination' ,
68
83
} ;
69
84
}
70
85
71
86
async getFinalizedBlockNumber ( ) : Promise < number > {
72
87
const query = this . makeGraphQLQuery ( 0 , 1 ) ;
73
- this . logger . debug ( `Query string = ${ JSON . stringify ( query ) } ` ) ;
88
+ // this.logger.debug(`Query string = ${JSON.stringify(query)}`);
74
89
const bulkTxnResult = (
75
90
await axios . post < SeiExplorerAccountTransactionsResponse > (
76
91
this . explorerGraphql ,
77
92
query ,
78
93
AXIOS_CONFIG_JSON
79
94
)
80
95
) . data ;
96
+ this . logger . debug ( `bulkTxnResult = ${ JSON . stringify ( bulkTxnResult ) } ` ) ;
81
97
const blockHeight = bulkTxnResult ?. data ?. account_transactions ?. [ 0 ] ?. block ?. height ;
82
98
if ( blockHeight ) {
83
99
if ( blockHeight !== this . latestBlockHeight ) {
@@ -111,7 +127,7 @@ export class SeiExplorerWatcher extends CosmwasmWatcher {
111
127
let skip : number = 0 ;
112
128
while ( ! done ) {
113
129
const query = this . makeGraphQLQuery ( skip , limit ) ;
114
- this . logger . debug ( `Query string = ${ JSON . stringify ( query ) } ` ) ;
130
+ // this.logger.debug(`Query string = ${JSON.stringify(query)}`);
115
131
const bulkTxnResult = (
116
132
await axios . post < SeiExplorerAccountTransactionsResponse > (
117
133
this . explorerGraphql ,
0 commit comments