Skip to content

Commit

Permalink
chore(deps): upgrade with new typemove package (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 authored Sep 19, 2023
1 parent 3a02cc1 commit 666a2f1
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 114 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-unused-imports": "^3.0.0",
"jest": "^29.6.4",
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@
},
"dependencies": {
"@coral-xyz/borsh": "^0.28.0",
"@mysten/sui.js": "^0.41.0",
"@mysten/sui.js": "~0.41.0",
"@project-serum/anchor": "^0.26.0",
"@sentio/bigdecimal": "^9.1.1-patch.3",
"@sentio/chain": "^1.0.4",
"@sentio/ethers-v6": "^1.0.28",
"@sentio/protos": "workspace:*",
"@sentio/runtime": "workspace:^",
"@solana/web3.js": "^1.78.3",
"@typemove/aptos": "^1.1.0",
"@typemove/move": "^1.1.0",
"@typemove/sui": "^1.1.0",
"aptos": "^1.19.0",
"@typemove/aptos": "~1.2.0",
"@typemove/move": "~1.2.0",
"@typemove/sui": "~1.2.0",
"aptos": "~1.19.0",
"aptos-sdk": "npm:aptos@^1.19.0",
"bs58": "^5.0.0",
"chalk": "^5.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/aptos/move-coder.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AptosNetwork, getRpcEndpoint } from './network.js'
import { AptosNetwork, getClient } from './network.js'
import { MoveCoder } from '@typemove/aptos'

const MOVE_CODER = new MoveCoder(getRpcEndpoint(AptosNetwork.MAIN_NET))
const TESTNET_MOVE_CODER = new MoveCoder(getRpcEndpoint(AptosNetwork.TEST_NET))
const MOVE_CODER = new MoveCoder(getClient(AptosNetwork.MAIN_NET))
const TESTNET_MOVE_CODER = new MoveCoder(getClient(AptosNetwork.TEST_NET))

export function defaultMoveCoder(network: AptosNetwork = AptosNetwork.MAIN_NET): MoveCoder {
if (network == AptosNetwork.MAIN_NET) {
Expand Down
10 changes: 10 additions & 0 deletions packages/sdk/src/aptos/network.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AptosChainId } from '@sentio/chain'
import { AptosClient } from 'aptos-sdk'
import { Labels } from '../core/index.js'
import { Endpoints } from '@sentio/runtime'

export type AptosNetwork = AptosChainId
export const AptosNetwork = <const>{
Expand All @@ -24,3 +25,12 @@ export function getRpcEndpoint(network: AptosNetwork): string {
}
return 'https://mainnet.aptoslabs.com/'
}

export function getClient(network: AptosNetwork): AptosClient {
let chainServer = Endpoints.INSTANCE.chainServer.get(network)
if (!chainServer) {
chainServer = getRpcEndpoint(network)
// throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
}
return new AptosClient(chainServer)
}
6 changes: 3 additions & 3 deletions packages/sdk/src/sui/move-coder.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { MoveCoder } from '@typemove/sui'

import { getRpcEndpoint, SuiNetwork } from './network.js'
import { getClient, SuiNetwork } from './network.js'

const MOVE_CODER = new MoveCoder(getRpcEndpoint(SuiNetwork.MAIN_NET))
const TESTNET_MOVE_CODER = new MoveCoder(getRpcEndpoint(SuiNetwork.TEST_NET))
const MOVE_CODER = new MoveCoder(getClient(SuiNetwork.MAIN_NET))
const TESTNET_MOVE_CODER = new MoveCoder(getClient(SuiNetwork.TEST_NET))

export function defaultMoveCoder(network: SuiNetwork = SuiNetwork.MAIN_NET): MoveCoder {
if (network == SuiNetwork.MAIN_NET) {
Expand Down
7 changes: 4 additions & 3 deletions packages/sdk/src/sui/network.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SuiChainId } from '@sentio/chain'
import { Endpoints } from '@sentio/runtime'
import { ServerError, Status } from 'nice-grpc'
// import { ServerError, Status } from 'nice-grpc'
import { SuiClient } from '@mysten/sui.js/client'

export type SuiNetwork = SuiChainId
Expand All @@ -11,9 +11,10 @@ export const SuiNetwork = <const>{
}

export function getClient(network: SuiNetwork): SuiClient {
const chainServer = Endpoints.INSTANCE.chainServer.get(network)
let chainServer = Endpoints.INSTANCE.chainServer.get(network)
if (!chainServer) {
throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
chainServer = getRpcEndpoint(network)
// throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
}
return new SuiClient({ url: chainServer })
}
Expand Down
123 changes: 24 additions & 99 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 666a2f1

Please sign in to comment.