@burnt-labs/account-management 0.0.1 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +7 -0
- package/.turbo/turbo-build.log +21 -0
- package/CHANGELOG.md +13 -0
- package/README.md +137 -0
- package/dist/index.d.ts +1308 -0
- package/dist/index.js +2252 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2186 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -13
- package/src/accounts/__tests__/discovery.test.ts +533 -0
- package/src/accounts/discovery.ts +77 -0
- package/src/accounts/index.ts +23 -0
- package/src/accounts/strategies/__tests__/account-composite-strategy.test.ts +245 -0
- package/src/accounts/strategies/__tests__/account-empty-strategy.test.ts +90 -0
- package/src/accounts/strategies/__tests__/account-numia-strategy.test.ts +309 -0
- package/src/accounts/strategies/__tests__/account-rpc-strategy.test.ts +296 -0
- package/src/accounts/strategies/__tests__/account-subquery-strategy.test.ts +124 -0
- package/src/accounts/strategies/__tests__/factory.test.ts +183 -0
- package/src/accounts/strategies/account-composite-strategy.ts +72 -0
- package/src/accounts/strategies/account-empty-strategy.ts +32 -0
- package/src/accounts/strategies/account-numia-strategy.ts +96 -0
- package/src/accounts/strategies/account-rpc-strategy.ts +212 -0
- package/src/accounts/strategies/account-subquery-strategy.ts +117 -0
- package/src/accounts/strategies/factory.ts +85 -0
- package/src/accounts/strategies/indexerConfigUtils.ts +75 -0
- package/src/authenticators/__tests__/utils.test.ts +281 -0
- package/src/authenticators/index.ts +6 -0
- package/src/authenticators/interfaces.ts +113 -0
- package/src/authenticators/jwt.ts +13 -0
- package/src/authenticators/utils.ts +86 -0
- package/src/grants/__tests__/construction.test.ts +1554 -0
- package/src/grants/__tests__/discovery.test.ts +384 -0
- package/src/grants/construction.ts +401 -0
- package/src/grants/discovery.ts +104 -0
- package/src/grants/index.ts +22 -0
- package/src/grants/strategies/__tests__/createCompositeTreasuryStrategy.test.ts +165 -0
- package/src/grants/strategies/__tests__/treasury-composite-strategy.test.ts +240 -0
- package/src/grants/strategies/__tests__/treasury-daodao-strategy.test.ts +226 -0
- package/src/grants/strategies/__tests__/treasury-direct-query-strategy.test.ts +281 -0
- package/src/grants/strategies/createCompositeTreasuryStrategy.ts +63 -0
- package/src/grants/strategies/index.ts +15 -0
- package/src/grants/strategies/treasury-composite-strategy.ts +72 -0
- package/src/grants/strategies/treasury-daodao-strategy.ts +242 -0
- package/src/grants/strategies/treasury-direct-query-strategy.ts +120 -0
- package/src/grants/utils/__tests__/authz.test.ts +354 -0
- package/src/grants/utils/__tests__/contract-validation.test.ts +441 -0
- package/src/grants/utils/__tests__/feegrant.test.ts +932 -0
- package/src/grants/utils/__tests__/format-permissions.test.ts +999 -0
- package/src/grants/utils/authz.ts +147 -0
- package/src/grants/utils/contract-validation.ts +247 -0
- package/src/grants/utils/feegrant.ts +321 -0
- package/src/grants/utils/format-permissions.ts +318 -0
- package/src/grants/utils/index.ts +8 -0
- package/src/index.ts +33 -0
- package/src/orchestrator/__tests__/orchestrator.test.ts +422 -0
- package/src/orchestrator/flow/__tests__/README.md +82 -0
- package/src/orchestrator/flow/__tests__/accountConnection.test.ts +458 -0
- package/src/orchestrator/flow/__tests__/grantCreation.test.ts +595 -0
- package/src/orchestrator/flow/__tests__/redirectFlow.test.ts +229 -0
- package/src/orchestrator/flow/__tests__/sessionRestoration.test.ts +493 -0
- package/src/orchestrator/flow/accountConnection.ts +189 -0
- package/src/orchestrator/flow/grantCreation.ts +338 -0
- package/src/orchestrator/flow/redirectFlow.ts +77 -0
- package/src/orchestrator/flow/sessionRestoration.ts +102 -0
- package/src/orchestrator/index.ts +10 -0
- package/src/orchestrator/orchestrator.ts +263 -0
- package/src/orchestrator/types.ts +128 -0
- package/src/state/__tests__/accountState.test.ts +978 -0
- package/src/state/accountState.ts +204 -0
- package/src/types/authenticator.ts +42 -0
- package/src/types/grants.ts +74 -0
- package/src/types/index.ts +39 -0
- package/src/types/indexer.ts +37 -0
- package/src/types/treasury.ts +70 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +11 -0
- package/vitest.config.integration.ts +28 -0
- package/vitest.config.ts +24 -0
- package/vitest.setup.ts +16 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
> @burnt-labs/account-management@1.0.0-alpha.2 build /home/runner/work/xion.js/xion.js/packages/account-management
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
CLI Building entry: src/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v6.7.0
|
|
8
|
+
CLI Using tsup config: /home/runner/work/xion.js/xion.js/packages/account-management/tsup.config.ts
|
|
9
|
+
CLI Target: es2020
|
|
10
|
+
CLI Cleaning output folder
|
|
11
|
+
CJS Build start
|
|
12
|
+
ESM Build start
|
|
13
|
+
DTS Build start
|
|
14
|
+
CJS dist/index.js 72.93 KB
|
|
15
|
+
CJS dist/index.js.map 170.42 KB
|
|
16
|
+
CJS ⚡️ Build success in 645ms
|
|
17
|
+
ESM dist/index.mjs 70.74 KB
|
|
18
|
+
ESM dist/index.mjs.map 170.42 KB
|
|
19
|
+
ESM ⚡️ Build success in 646ms
|
|
20
|
+
DTS ⚡️ Build success in 2856ms
|
|
21
|
+
DTS dist/index.d.ts 47.79 KB
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @burnt-labs/account-management
|
|
2
|
+
|
|
3
|
+
## 1.0.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#314](https://github.com/burnt-labs/xion.js/pull/314) [`f7359df`](https://github.com/burnt-labs/xion.js/commit/f7359dfdb0d3de55f51b7d8abcfa2e3c7baeb8e9) Thanks [@ertemann](https://github.com/ertemann)! - This release introduces **Signer Mode**, allowing users to connect with external wallets (MetaMask, Keplr, OKX, Turnkey, etc.) without requiring dashboard redirects. We've also refactored Abstraxion with a new connector-based architecture for better flexibility and extensibility. The release includes automatic configuration defaults (rpcUrl, restUrl, gasPrice are now inferred from chainId), migration to AA API V2, and two new packages: `@burnt-labs/account-management` and `@burnt-labs/signers`. Indexer support has been added for fast account discovery using Numia, Subquery, and DaoDao indexers. The Direct Signer Mode has been removed in favor of the new Signer Mode. Existing redirect mode users require no changes, while signer mode users need to add an `authentication` config with `type: "signer"`, `aaApiUrl`, `getSignerConfig()`, and `smartAccountContract` settings.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`f7359df`](https://github.com/burnt-labs/xion.js/commit/f7359dfdb0d3de55f51b7d8abcfa2e3c7baeb8e9)]:
|
|
12
|
+
- @burnt-labs/abstraxion-core@1.0.0-alpha.62
|
|
13
|
+
- @burnt-labs/signers@1.0.0-alpha.2
|
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# @burnt-labs/account-management
|
|
2
|
+
|
|
3
|
+
Smart account management utilities for XION blockchain.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides comprehensive account and grant management for XION's smart accounts, supporting multiple discovery strategies and treasury integrations.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Account Discovery**: Multiple strategies for finding smart accounts
|
|
12
|
+
- Numia indexer integration
|
|
13
|
+
- Subquery indexer integration
|
|
14
|
+
- Direct RPC queries
|
|
15
|
+
- Composite fallback chains
|
|
16
|
+
|
|
17
|
+
- **Treasury Management**: Flexible treasury configuration retrieval
|
|
18
|
+
- Direct contract queries
|
|
19
|
+
- DAO DAO indexer integration
|
|
20
|
+
- Composite strategy support
|
|
21
|
+
|
|
22
|
+
- **Connection Orchestration**: High-level API for managing account connections, grants, and redirects
|
|
23
|
+
|
|
24
|
+
## Testing
|
|
25
|
+
|
|
26
|
+
### Test Structure
|
|
27
|
+
|
|
28
|
+
The package uses a comprehensive unit testing approach with Vitest:
|
|
29
|
+
|
|
30
|
+
- **Unit Tests**: Located in `src/**/__tests__/` directories alongside source code
|
|
31
|
+
- **Integration Tests**: Located in `tests/integration/` (requires live RPC endpoints)
|
|
32
|
+
|
|
33
|
+
### Running Tests
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Run all tests in watch mode
|
|
37
|
+
pnpm test
|
|
38
|
+
|
|
39
|
+
# Run unit tests once
|
|
40
|
+
pnpm test:unit
|
|
41
|
+
|
|
42
|
+
# Run unit tests with coverage report
|
|
43
|
+
pnpm test:coverage
|
|
44
|
+
|
|
45
|
+
# Run integration tests (requires .env.test configuration)
|
|
46
|
+
pnpm test:integration
|
|
47
|
+
|
|
48
|
+
# Run integration tests in watch mode
|
|
49
|
+
pnpm test:integration:watch
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Coverage Requirements
|
|
53
|
+
|
|
54
|
+
The unit tests target 70%+ coverage for core modules:
|
|
55
|
+
|
|
56
|
+
- **Account Strategies**: 86.56% coverage
|
|
57
|
+
- EmptyAccountStrategy: 100%
|
|
58
|
+
- CompositeAccountStrategy: 100%
|
|
59
|
+
- NumiaAccountStrategy: 100%
|
|
60
|
+
- RpcAccountStrategy: 93.75%
|
|
61
|
+
- SubqueryAccountStrategy: 96.58%
|
|
62
|
+
- Factory: 100%
|
|
63
|
+
|
|
64
|
+
- **Treasury Strategies**: 93% coverage
|
|
65
|
+
- CompositeTreasuryStrategy: 100%
|
|
66
|
+
- DirectQueryTreasuryStrategy: 100%
|
|
67
|
+
- DaoDaoTreasuryStrategy: 91.32%
|
|
68
|
+
- createCompositeTreasuryStrategy: 100%
|
|
69
|
+
|
|
70
|
+
- **Orchestrator**: 66.17% coverage
|
|
71
|
+
- orchestrator.ts: 100%
|
|
72
|
+
- redirectFlow.ts: 100%
|
|
73
|
+
|
|
74
|
+
### Test Organization
|
|
75
|
+
|
|
76
|
+
Tests are organized by module:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
src/
|
|
80
|
+
├── accounts/
|
|
81
|
+
│ └── strategies/
|
|
82
|
+
│ └── __tests__/
|
|
83
|
+
│ ├── account-empty-strategy.test.ts
|
|
84
|
+
│ ├── account-composite-strategy.test.ts
|
|
85
|
+
│ ├── account-numia-strategy.test.ts
|
|
86
|
+
│ ├── account-rpc-strategy.test.ts
|
|
87
|
+
│ ├── account-subquery-strategy.test.ts
|
|
88
|
+
│ └── factory.test.ts
|
|
89
|
+
├── grants/
|
|
90
|
+
│ └── strategies/
|
|
91
|
+
│ └── __tests__/
|
|
92
|
+
│ ├── treasury-composite-strategy.test.ts
|
|
93
|
+
│ ├── treasury-daodao-strategy.test.ts
|
|
94
|
+
│ ├── treasury-direct-query-strategy.test.ts
|
|
95
|
+
│ └── createCompositeTreasuryStrategy.test.ts
|
|
96
|
+
└── orchestrator/
|
|
97
|
+
├── __tests__/
|
|
98
|
+
│ └── orchestrator.test.ts
|
|
99
|
+
└── flow/
|
|
100
|
+
└── __tests__/
|
|
101
|
+
└── redirectFlow.test.ts
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Integration Testing
|
|
105
|
+
|
|
106
|
+
Integration tests require a live XION RPC endpoint. Configure by creating [.env.test](.env.test):
|
|
107
|
+
|
|
108
|
+
```env
|
|
109
|
+
XION_RPC_URL=https://rpc.xion-testnet-1.burnt.com:443
|
|
110
|
+
XION_CHAIN_ID=xion-testnet-1
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
See [vitest.config.integration.ts](vitest.config.integration.ts) for integration test configuration.
|
|
114
|
+
|
|
115
|
+
### Mocking Strategy
|
|
116
|
+
|
|
117
|
+
The tests use Vitest's mocking capabilities:
|
|
118
|
+
|
|
119
|
+
- **External APIs**: Mocked with `vi.fn()` and `global.fetch`
|
|
120
|
+
- **CosmJS**: Mocked CosmWasmClient for RPC interactions
|
|
121
|
+
- **WebAuthn**: Globally mocked in the signers package to avoid Node.js compatibility issues
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Build the package
|
|
127
|
+
pnpm build
|
|
128
|
+
|
|
129
|
+
# Run in development mode (watch)
|
|
130
|
+
pnpm dev
|
|
131
|
+
|
|
132
|
+
# Type checking
|
|
133
|
+
pnpm check-types
|
|
134
|
+
|
|
135
|
+
# Linting
|
|
136
|
+
pnpm lint
|
|
137
|
+
```
|