Skip to content

Commit bb3185e

Browse files
committed
watcher: sei for testnet
1 parent 5bbb888 commit bb3185e

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

watcher/src/watchers/SeiExplorerWatcher.ts

+22-6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type SeiExplorerAccountTransactionsResponse = {
3737
export class SeiExplorerWatcher extends CosmwasmWatcher {
3838
explorerGraphql: string;
3939
explorerTxs: string;
40+
accountId: number;
4041

4142
constructor(network: Environment) {
4243
super(network, 'sei');
@@ -54,30 +55,45 @@ export class SeiExplorerWatcher extends CosmwasmWatcher {
5455
: network === 'testnet'
5556
? SEI_EXPLORER_TXS_TESTNET
5657
: '';
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
5775
}
5876

5977
makeGraphQLQuery(offset: number, pageSize: number) {
6078
return {
6179
query:
6280
'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 },
6782
operationName: 'getTxsByAddressPagination',
6883
};
6984
}
7085

7186
async getFinalizedBlockNumber(): Promise<number> {
7287
const query = this.makeGraphQLQuery(0, 1);
73-
this.logger.debug(`Query string = ${JSON.stringify(query)}`);
88+
// this.logger.debug(`Query string = ${JSON.stringify(query)}`);
7489
const bulkTxnResult = (
7590
await axios.post<SeiExplorerAccountTransactionsResponse>(
7691
this.explorerGraphql,
7792
query,
7893
AXIOS_CONFIG_JSON
7994
)
8095
).data;
96+
this.logger.debug(`bulkTxnResult = ${JSON.stringify(bulkTxnResult)}`);
8197
const blockHeight = bulkTxnResult?.data?.account_transactions?.[0]?.block?.height;
8298
if (blockHeight) {
8399
if (blockHeight !== this.latestBlockHeight) {
@@ -111,7 +127,7 @@ export class SeiExplorerWatcher extends CosmwasmWatcher {
111127
let skip: number = 0;
112128
while (!done) {
113129
const query = this.makeGraphQLQuery(skip, limit);
114-
this.logger.debug(`Query string = ${JSON.stringify(query)}`);
130+
// this.logger.debug(`Query string = ${JSON.stringify(query)}`);
115131
const bulkTxnResult = (
116132
await axios.post<SeiExplorerAccountTransactionsResponse>(
117133
this.explorerGraphql,

0 commit comments

Comments
 (0)