Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,18 @@ jobs:
env:
GITHUB_PAGES: 'true'
VITE_OMS_PUBLISHABLE_KEY: ${{ secrets.OMS_PUBLISHABLE_KEY }}
VITE_OMS_PROJECT_ID: ${{ secrets.OMS_PROJECT_ID }}

- name: Build Trails Actions example
run: pnpm build:trails-actions-example
env:
GITHUB_PAGES: 'true'
VITE_OMS_PUBLISHABLE_KEY: ${{ secrets.OMS_PUBLISHABLE_KEY }}
VITE_OMS_PROJECT_ID: ${{ secrets.OMS_PROJECT_ID }}

- name: Build Wagmi example
run: pnpm build:wagmi-example
env:
GITHUB_PAGES: 'true'
VITE_OMS_PUBLISHABLE_KEY: ${{ secrets.OMS_PUBLISHABLE_KEY }}
VITE_OMS_PROJECT_ID: ${{ secrets.OMS_PROJECT_ID }}
VITE_TRAILS_API_KEY: ${{ secrets.VITE_TRAILS_API_KEY }}

- name: Stage Pages artifact
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,15 @@ jobs:
- name: Build React example
run: pnpm build:example
env:
VITE_OMS_PUBLISHABLE_KEY: ci-publishable-key
VITE_OMS_PROJECT_ID: ci-project-id
VITE_OMS_PUBLISHABLE_KEY: pk_ci_sdbx_ciproject_cikey

- name: Build Trails Actions example
run: pnpm build:trails-actions-example
env:
VITE_OMS_PUBLISHABLE_KEY: ci-publishable-key
VITE_OMS_PROJECT_ID: ci-project-id
VITE_OMS_PUBLISHABLE_KEY: pk_ci_sdbx_ciproject_cikey

- name: Build Wagmi example
run: pnpm --filter wagmi-example build
env:
VITE_OMS_PUBLISHABLE_KEY: ci-publishable-key
VITE_OMS_PROJECT_ID: ci-project-id
VITE_OMS_PUBLISHABLE_KEY: pk_ci_sdbx_ciproject_cikey
VITE_TRAILS_API_KEY: ci-trails-key
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ execution commands.
## Security and Configuration

- Do not commit real secrets. `.env.local` and `.env.*.local` files are ignored for local overrides.
- The React example uses `examples/react/.env.example` for `VITE_OMS_PUBLISHABLE_KEY` and `VITE_OMS_PROJECT_ID`; keep local overrides in `examples/react/.env.local`.
- The wagmi React example uses `examples/wagmi/.env.example` for `VITE_OMS_PUBLISHABLE_KEY` and `VITE_OMS_PROJECT_ID`; keep local overrides in `examples/wagmi/.env.local`.
- The React example uses `examples/react/.env.example` for `VITE_OMS_PUBLISHABLE_KEY`; keep local overrides in `examples/react/.env.local`.
- The wagmi React example uses `examples/wagmi/.env.example` for `VITE_OMS_PUBLISHABLE_KEY`; keep local overrides in `examples/wagmi/.env.local`.
- Treat credential signing, nonce handling, OIDC redirect state cleanup, session persistence, transaction execution/status polling, and access revocation as high-risk paths. Prefer focused regression tests for changes in these areas.
- GitHub Pages reads `OMS_PUBLISHABLE_KEY` and `OMS_PROJECT_ID` for deployed examples. The wagmi example also reads `VITE_TRAILS_API_KEY`. Do not require those secrets for ordinary local unit tests unless the test explicitly needs an external boundary.
- GitHub Pages reads `OMS_PUBLISHABLE_KEY` for deployed examples. The wagmi example also reads `VITE_TRAILS_API_KEY`. Do not require those secrets for ordinary local unit tests unless the test explicitly needs an external boundary.

## Agent Workflow Rules

Expand Down
119 changes: 79 additions & 40 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
- [listAccessPages](#listaccesspages)
- [revokeAccess](#revokeaccess)
- [IndexerClient](#indexerclient)
- [getTokenBalances](#gettokenbalances)
- [getNativeTokenBalance](#getnativetokenbalance)
- [getBalances](#getbalances)
- [getTransactionHistory](#gettransactionhistory)
- [Errors](#errors)
- [Types](#types)
- [Network](#network)
Expand All @@ -55,7 +55,8 @@
- [SendTransactionResponse](#sendtransactionresponse)
- [TransactionStatusPollingOptions](#transactionstatuspollingoptions)
- [FeeOptionSelector](#feeoptionselector)
- [TokenBalancesResult](#tokenbalancesresult)
- [BalancesResult](#balancesresult)
- [TransactionHistoryResult](#transactionhistoryresult)
- [TokenBalancesPage](#tokenbalancespage)
- [TokenBalance](#tokenbalance)
- [TokenContractInfo](#tokencontractinfo)
Expand All @@ -75,7 +76,6 @@ import { OMSClient } from '@0xsequence/typescript-sdk'

const oms = new OMSClient({
publishableKey: 'your-publishable-key',
projectId: 'your-project-id',
})
```

Expand All @@ -84,7 +84,6 @@ const oms = new OMSClient({
```typescript
new OMSClient(params: {
publishableKey: string
projectId: string
environment?: OmsEnvironment
storage?: StorageManager
redirectAuthStorage?: StorageManager
Expand All @@ -96,8 +95,7 @@ new OMSClient(params: {

| Name | Type | Required | Description |
|---|---|---|---|
| `publishableKey` | `string` | Yes | Your OMS publishable key. |
| `projectId` | `string` | Yes | Your OMS project ID. Used as the WaaS signing scope for wallet requests and OIDC redirect state. |
| `publishableKey` | `string` | Yes | Your OMS publishable key. Wallet and IndexerGateway requests send this as the `Api-Key` header. |
| `environment` | `OmsEnvironment` | No | API endpoint configuration. Defaults to the SDK's configured OMS endpoints. |
| `storage` | `StorageManager` | No | Storage backend for wallet metadata. Defaults to `LocalStorageManager` when browser `localStorage` is available, otherwise `MemoryStorageManager`. |
| `redirectAuthStorage` | `StorageManager` | No | Transient storage for OIDC redirect verifier/state. Defaults to `sessionStorage` when available. |
Expand Down Expand Up @@ -700,66 +698,83 @@ if (other) {

## IndexerClient

Accessed via `oms.indexer`. Queries on-chain token balances through the OMS Indexer API.
Accessed via `oms.indexer`. Queries on-chain balances and transaction history through IndexerGateway.

### getTokenBalances
### getBalances

```typescript
getTokenBalances(params: {
network: Network
contractAddress?: string
getBalances(params: {
walletAddress: string
includeMetadata: boolean
page?: {
page?: number
pageSize?: number
}
}): Promise<TokenBalancesResult>
networks?: Network[]
networkType?: 'MAINNETS' | 'TESTNETS' | 'ALL'
contractAddresses?: string[]
includeMetadata?: boolean
omitPrices?: boolean
tokenIds?: string[]
page?: TokenBalancesPage
}): Promise<BalancesResult>
```

Fetches token balances for a wallet on a given network. Omit `contractAddress` to query balances across contracts; provide it to filter to one token contract. The default request returns page `0` with up to `40` entries. When `includeMetadata` is `true`, token display data is returned on `contractInfo` and `tokenMetadata`; ERC-20 decimals are available as `contractInfo.decimals`.
Fetches native and token balances for a wallet. Pass `networks` to query explicit SDK network objects. If `networks` is omitted, the request defaults to `networkType: 'MAINNETS'`. The default request returns page `0` with up to `40` entries. `includeMetadata` defaults to `true`; token display data is returned on `contractInfo` and `tokenMetadata`, and ERC-20 decimals are available as `contractInfo.decimals`.

**Parameters**

| Name | Type | Description |
|---|---|---|
| `network` | `Network` | The network to query. Use an exported registry value such as `Networks.polygon`. |
| `contractAddress` | `string` | Optional token contract filter. Omit to query balances across contracts. |
| `walletAddress` | `string` | The wallet address whose balances to fetch. Use `oms.wallet.walletAddress` after checking it is defined. |
| `includeMetadata` | `boolean` | When `true`, the response includes token metadata such as name, symbol, and decimals. |
| `page` | `{ page?: number; pageSize?: number }` | Optional pagination request. Defaults to `{ page: 0, pageSize: 40 }`. |
| `networks` | `Network[]` | Optional explicit networks to query. Use exported registry values such as `Networks.polygon`. |
| `networkType` | `'MAINNETS' \| 'TESTNETS' \| 'ALL'` | Optional gateway network group when `networks` is omitted. Defaults to `'MAINNETS'`. |
| `contractAddresses` | `string[]` | Optional token contract filter. Omit to query balances across contracts. |
| `includeMetadata` | `boolean` | Optional metadata flag. Defaults to `true`. |
| `omitPrices` | `boolean` | Optional price exclusion flag. |
| `tokenIds` | `string[]` | Optional token ID filter. |
| `page` | `TokenBalancesPage` | Optional pagination request. Defaults to `{ page: 0, pageSize: 40 }`. |

**Returns** `Promise<TokenBalancesResult>` — see [TokenBalancesResult](#tokenbalancesresult).
**Returns** `Promise<BalancesResult>` — see [BalancesResult](#balancesresult).

**Example**

```typescript
const { walletAddress } = oms.wallet
if (!walletAddress) throw new Error('No active wallet session')

const result = await oms.indexer.getTokenBalances({
network: Networks.polygon,
const result = await oms.indexer.getBalances({
networks: [Networks.polygon],
walletAddress,
includeMetadata: true,
})

for (const b of result.nativeBalances) {
console.log(b.symbol, b.balance)
}

for (const b of result.balances) {
console.log(b.contractAddress, b.balance, b.tokenId)
}
```

---

### getNativeTokenBalance
### getTransactionHistory

```typescript
getNativeTokenBalance(params: {
network: Network
getTransactionHistory(params: {
walletAddress: string
}): Promise<TokenBalance | undefined>
networks?: Network[]
networkType?: 'MAINNETS' | 'TESTNETS' | 'ALL'
contractAddresses?: string[]
transactionHashes?: string[]
metaTransactionIds?: string[]
fromBlock?: number
toBlock?: number
tokenId?: string
includeMetadata?: boolean
omitPrices?: boolean
page?: TokenBalancesPage
}): Promise<TransactionHistoryResult>
```

Fetches the native token balance for a wallet. This is also used internally to enrich transaction fee options.
Fetches mined transaction history for a wallet. Pass `networks` to query explicit SDK network objects. If `networks` is omitted, the request defaults to `networkType: 'MAINNETS'`. `includeMetadata` defaults to `true`.

---

Expand Down Expand Up @@ -874,7 +889,7 @@ findNetworkByName(name: string): Network | undefined
```typescript
interface OmsEnvironment {
walletApiUrl: string
indexerUrlTemplate: string
indexerGatewayUrl: string
auth?: {
oidcProviders?: Record<string, OidcProviderConfig>
}
Expand All @@ -884,10 +899,10 @@ interface OmsEnvironment {
| Field | Type | Description |
|---|---|---|
| `walletApiUrl` | `string` | Base URL of the WaaS Wallet RPC host. |
| `indexerUrlTemplate` | `string` | URL template for the Indexer API. `{value}` is replaced with the selected network name, e.g. `"https://indexer.example.com/{value}"`. |
| `indexerGatewayUrl` | `string` | Base URL of the IndexerGateway host, e.g. `"https://api.example.com/v1/IndexerGateway/"`. |
| `auth.oidcProviders` | `Record<string, OidcProviderConfig>` | OIDC provider configurations addressable by provider key. |

The default is exported as `defaultOmsEnvironment` and includes the `google` OIDC provider.
The default is exported as `defaultOmsEnvironment`, uses `https://sandbox-api.dev.polygon-dev.technology` as the WaaS API base URL, and includes the `google` OIDC provider.

Use `defineOmsEnvironment` to preserve typed custom OIDC provider keys:

Expand Down Expand Up @@ -1182,12 +1197,13 @@ that fee option.

---

### TokenBalancesResult
### BalancesResult

```typescript
interface TokenBalancesResult {
interface BalancesResult {
status: number
page?: TokenBalancesPage
nativeBalances: TokenBalance[]
balances: TokenBalance[]
}
```
Expand All @@ -1196,25 +1212,48 @@ interface TokenBalancesResult {
|---|---|---|
| `status` | `number` | HTTP status code of the indexer response. |
| `page` | `TokenBalancesPage` | Pagination metadata, if present. |
| `nativeBalances` | `TokenBalance[]` | Native token balances for the requested address. |
| `balances` | `TokenBalance[]` | Array of token balance entries for the requested address. |

---

### TransactionHistoryResult

```typescript
interface TransactionHistoryResult {
status: number
page?: TokenBalancesPage
transactions: Transaction[]
}
```

| Field | Type | Description |
|---|---|---|
| `status` | `number` | HTTP status code of the indexer response. |
| `page` | `TokenBalancesPage` | Pagination metadata, if present. |
| `transactions` | `Transaction[]` | Flattened transaction entries across the requested networks. |

---

### TokenBalancesPage

```typescript
interface TokenBalancesPage {
page: number
pageSize: number
more: boolean
page?: number
pageSize?: number
more?: boolean
before?: unknown
after?: unknown
}
```

| Field | Type | Description |
|---|---|---|
| `page` | `number` | Current page index (zero-based). |
| `pageSize` | `number` | Number of entries per page (up to 40). |
| `pageSize` | `number` | Number of entries per page. |
| `more` | `boolean` | `true` if additional pages are available. |
| `before` | `unknown` | Gateway cursor before the current page, when returned. |
| `after` | `unknown` | Gateway cursor after the current page, when returned. |

---

Expand Down
Loading
Loading