@burnt-labs/account-management 1.0.0-alpha.12 → 1.0.0-alpha.13
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +14 -0
- package/dist/index.d.ts +33 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/grants/__tests__/revoke.test.ts +97 -0
- package/src/grants/index.ts +3 -0
- package/src/grants/revoke.ts +89 -0
- package/src/grants/strategies/__tests__/treasury-composite-strategy.test.ts +37 -0
- package/src/grants/strategies/__tests__/treasury-daodao-strategy.test.ts +96 -0
- package/src/grants/strategies/treasury-daodao-strategy.ts +34 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @burnt-labs/account-management@1.0.0-alpha.
|
|
2
|
+
> @burnt-labs/account-management@1.0.0-alpha.13 build /home/runner/work/xion.js/xion.js/packages/account-management
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
12
|
[34mESM[39m Build start
|
|
13
13
|
[34mDTS[39m Build start
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
15
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
16
|
-
[32mCJS[39m ⚡️ Build success in
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
18
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
19
|
-
[32mESM[39m ⚡️ Build success in
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m79.86 KB[39m
|
|
15
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m192.40 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 483ms
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m77.58 KB[39m
|
|
18
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m192.40 KB[39m
|
|
19
|
+
[32mESM[39m ⚡️ Build success in 484ms
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 2775ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m53.91 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @burnt-labs/account-management
|
|
2
2
|
|
|
3
|
+
## 1.0.0-alpha.13
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#383](https://github.com/burnt-labs/xion.js/pull/383) [`8905566`](https://github.com/burnt-labs/xion.js/commit/89055662d91e4a4e1bf64f990f494cee3db3a76c) Thanks [@ertemann](https://github.com/ertemann)! - feat(account-management): add `getMsgTypeUrlForRevoke(authorizationTypeUrl, stakeAuthType?)` pure helper in `grants/` (exported from `@burnt-labs/account-management`). Maps an authz authorization `@type` to the `MsgRevoke`-able msg type URL, including the `StakeAuthorization` delegate/undelegate/redelegate variants (keyed by enum name or numeric proto value). Lets dashboard/xion-app consumers drop their local copies.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#383](https://github.com/burnt-labs/xion.js/pull/383) [`8905566`](https://github.com/burnt-labs/xion.js/commit/89055662d91e4a4e1bf64f990f494cee3db3a76c) Thanks [@ertemann](https://github.com/ertemann)! - fix(account-management): reject the DaoDao indexer's unindexed-treasury placeholder. The indexer returns `{ admin: null, grantConfigs: {}, … }` (not a 404) for any contract it hasn't indexed; `DaoDaoTreasuryStrategy.validateAllResponse` now rejects when `admin` is null/absent instead of accepting it as a successful empty config. In a racing `CompositeTreasuryStrategy` this lets `DirectQueryTreasuryStrategy` win, so an un-indexed treasury no longer silently degrades the connect screen to "Read access only".
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`8905566`](https://github.com/burnt-labs/xion.js/commit/89055662d91e4a4e1bf64f990f494cee3db3a76c), [`8905566`](https://github.com/burnt-labs/xion.js/commit/89055662d91e4a4e1bf64f990f494cee3db3a76c)]:
|
|
14
|
+
- @burnt-labs/signers@1.0.0-alpha.10
|
|
15
|
+
- @burnt-labs/abstraxion-core@1.0.0-alpha.72
|
|
16
|
+
|
|
3
17
|
## 1.0.0-alpha.12
|
|
4
18
|
|
|
5
19
|
### Major Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -263,6 +263,38 @@ declare function buildGrantMessages(params: {
|
|
|
263
263
|
stake?: boolean;
|
|
264
264
|
}): EncodeObject[];
|
|
265
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Authorization → revoke message-type mapping
|
|
268
|
+
*
|
|
269
|
+
* Pure helpers for translating an authz authorization `@type` into the message
|
|
270
|
+
* type URL that a `MsgRevoke` must target in order to remove that grant.
|
|
271
|
+
*/
|
|
272
|
+
/** The authz `@type` for staking authorizations, handled specially below. */
|
|
273
|
+
declare const STAKE_AUTHORIZATION_TYPE_URL = "/cosmos.staking.v1beta1.StakeAuthorization";
|
|
274
|
+
/**
|
|
275
|
+
* Resolve the message type URL a `MsgRevoke` must target to remove a grant of
|
|
276
|
+
* the given authorization type.
|
|
277
|
+
*
|
|
278
|
+
* `MsgRevoke` identifies a grant by its `msgTypeUrl`, which is *not* the
|
|
279
|
+
* authorization's own `@type` — e.g. revoking a `SendAuthorization` requires
|
|
280
|
+
* `msgTypeUrl: "/cosmos.bank.v1beta1.MsgSend"`. This is a pure lookup over the
|
|
281
|
+
* known authz authorization types.
|
|
282
|
+
*
|
|
283
|
+
* For `StakeAuthorization`, the target depends on the authorization's
|
|
284
|
+
* `authorization_type`; pass it via `stakeAuthType` (accepts either the enum
|
|
285
|
+
* name, e.g. `"AUTHORIZATION_TYPE_DELEGATE"`, or its numeric proto value, e.g.
|
|
286
|
+
* `1` / `"1"`).
|
|
287
|
+
*
|
|
288
|
+
* For unrecognized inputs — including `GenericAuthorization`, whose revoke
|
|
289
|
+
* target is its own runtime `msg` field — the `authorizationTypeUrl` is
|
|
290
|
+
* returned unchanged so callers can decide how to handle it.
|
|
291
|
+
*
|
|
292
|
+
* @param authorizationTypeUrl - The authz authorization `@type`
|
|
293
|
+
* @param stakeAuthType - Staking authorization type (enum name or numeric value); only used for `StakeAuthorization`
|
|
294
|
+
* @returns The msg type URL to revoke, or `authorizationTypeUrl` if unmapped
|
|
295
|
+
*/
|
|
296
|
+
declare function getMsgTypeUrlForRevoke(authorizationTypeUrl: string, stakeAuthType?: number | string): string;
|
|
297
|
+
|
|
266
298
|
/**
|
|
267
299
|
* Error for invalid contract grant configuration
|
|
268
300
|
*/
|
|
@@ -1413,4 +1445,4 @@ declare function isUrlSafe(url: string | undefined): boolean;
|
|
|
1413
1445
|
*/
|
|
1414
1446
|
declare function urlsMatch(urlA: string | undefined, urlB: string | undefined): boolean;
|
|
1415
1447
|
|
|
1416
|
-
export { AccountConnectionParams, AccountCreationConfig, AccountExistenceResult, AccountIndexerConfig, AccountInfo, AccountState, AccountStateAction, AccountStateGuards, AddressValidationError, AllSmartWalletQueryResponse, Allowance, AllowanceResponse, Authenticator, BaseAllowance, CompositeAccountStrategy, CompositeTreasuryStrategy, CompositeTreasuryStrategyOptions, ConnectionOrchestrator, ConnectionOrchestratorConfig, ConnectionResult, ContractValidationResult, ContractsAllowance, CosmosAuthzPermission, CreateCompositeAccountStrategyConfig, CreateCompositeTreasuryStrategyConfig, DENOM_DECIMALS, DENOM_DISPLAY_MAP, DaoDaoTreasuryStrategy, DaoDaoTreasuryStrategyConfig, DirectQueryTreasuryStrategy, EmptyAccountStrategy, FeeGrantValidationError, FeeGrantValidationResult, FormattedDescriptions, GeneratedAuthzGrantMessage, GrantConfig, GrantConfigByTypeUrl, GrantConfigTypeUrlsResponse, GrantCreationParams, GrantCreationResult, IndexerStrategy, InvalidAllowanceError, InvalidContractGrantError, MultiAnyAllowance, NumiaAccountStrategy, PermissionDescription, RpcAccountStrategy, RpcAccountStrategyConfig, SelectedSmartAccount, SessionManager, SessionRestorationResult, SigningClientConfig, SmartAccount$1 as SmartAccount, SmartAccountContractConfig, SmartAccountWithCodeId, SubqueryAccountStrategy, TreasuryConfig, TreasuryContractResponse, TreasuryParams, TreasuryStrategy, UserIndexerConfig, accountStateReducer, buildGrantMessages, checkAccountExists, checkStorageGrants, completeRedirect, connectAccount, convertIndexerConfig, createCompositeAccountStrategy, createCompositeTreasuryStrategy, createGrants, createJwtAuthenticatorIdentifier, deduplicateAccountsById, extractIndexerAuthToken, findBestMatchingAuthenticator, formatCoinArray, formatCoins, formatValidationErrors, formatXionAmount, generateBankGrant, generateContractGrant, generatePermissionDescriptions, generateStakeAndGovGrant, generateTreasuryGrants, getAccountInfoFromRestored, getContractAddress, getDomainAndProtocol, initiateRedirect, isContractGrantConfigValid, isDuplicateAuthenticator, isSelfReferentialGrant, isSessionRestorationError, isSessionRestored, isUrlSafe, isValidTransition, parseCoinString, queryTreasuryContractWithPermissions, restoreSession, urlsMatch, validateActions, validateContractAddressFormat, validateContractGrants, validateContractGrantsOrThrow, validateFeeGrant, validateNewAuthenticator, verifyContractExists };
|
|
1448
|
+
export { AccountConnectionParams, AccountCreationConfig, AccountExistenceResult, AccountIndexerConfig, AccountInfo, AccountState, AccountStateAction, AccountStateGuards, AddressValidationError, AllSmartWalletQueryResponse, Allowance, AllowanceResponse, Authenticator, BaseAllowance, CompositeAccountStrategy, CompositeTreasuryStrategy, CompositeTreasuryStrategyOptions, ConnectionOrchestrator, ConnectionOrchestratorConfig, ConnectionResult, ContractValidationResult, ContractsAllowance, CosmosAuthzPermission, CreateCompositeAccountStrategyConfig, CreateCompositeTreasuryStrategyConfig, DENOM_DECIMALS, DENOM_DISPLAY_MAP, DaoDaoTreasuryStrategy, DaoDaoTreasuryStrategyConfig, DirectQueryTreasuryStrategy, EmptyAccountStrategy, FeeGrantValidationError, FeeGrantValidationResult, FormattedDescriptions, GeneratedAuthzGrantMessage, GrantConfig, GrantConfigByTypeUrl, GrantConfigTypeUrlsResponse, GrantCreationParams, GrantCreationResult, IndexerStrategy, InvalidAllowanceError, InvalidContractGrantError, MultiAnyAllowance, NumiaAccountStrategy, PermissionDescription, RpcAccountStrategy, RpcAccountStrategyConfig, STAKE_AUTHORIZATION_TYPE_URL, SelectedSmartAccount, SessionManager, SessionRestorationResult, SigningClientConfig, SmartAccount$1 as SmartAccount, SmartAccountContractConfig, SmartAccountWithCodeId, SubqueryAccountStrategy, TreasuryConfig, TreasuryContractResponse, TreasuryParams, TreasuryStrategy, UserIndexerConfig, accountStateReducer, buildGrantMessages, checkAccountExists, checkStorageGrants, completeRedirect, connectAccount, convertIndexerConfig, createCompositeAccountStrategy, createCompositeTreasuryStrategy, createGrants, createJwtAuthenticatorIdentifier, deduplicateAccountsById, extractIndexerAuthToken, findBestMatchingAuthenticator, formatCoinArray, formatCoins, formatValidationErrors, formatXionAmount, generateBankGrant, generateContractGrant, generatePermissionDescriptions, generateStakeAndGovGrant, generateTreasuryGrants, getAccountInfoFromRestored, getContractAddress, getDomainAndProtocol, getMsgTypeUrlForRevoke, initiateRedirect, isContractGrantConfigValid, isDuplicateAuthenticator, isSelfReferentialGrant, isSessionRestorationError, isSessionRestored, isUrlSafe, isValidTransition, parseCoinString, queryTreasuryContractWithPermissions, restoreSession, urlsMatch, validateActions, validateContractAddressFormat, validateContractGrants, validateContractGrantsOrThrow, validateFeeGrant, validateNewAuthenticator, verifyContractExists };
|
package/dist/index.js
CHANGED
|
@@ -652,6 +652,33 @@ function buildGrantMessages(params) {
|
|
|
652
652
|
return messages;
|
|
653
653
|
}
|
|
654
654
|
|
|
655
|
+
// src/grants/revoke.ts
|
|
656
|
+
var STAKE_AUTHORIZATION_TYPE_URL = "/cosmos.staking.v1beta1.StakeAuthorization";
|
|
657
|
+
var REVOKE_MSG_TYPE_URL_BY_AUTHORIZATION = {
|
|
658
|
+
"/cosmos.bank.v1beta1.SendAuthorization": "/cosmos.bank.v1beta1.MsgSend",
|
|
659
|
+
"/cosmos.gov.v1beta1.VoteAuthorization": "/cosmos.gov.v1beta1.MsgVote",
|
|
660
|
+
"/cosmos.gov.v1.VoteAuthorization": "/cosmos.gov.v1.MsgVote",
|
|
661
|
+
"/ibc.applications.transfer.v1.TransferAuthorization": "/ibc.applications.transfer.v1.MsgTransfer",
|
|
662
|
+
"/cosmwasm.wasm.v1.ContractExecutionAuthorization": "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
663
|
+
"/cosmwasm.wasm.v1.ContractMigrationAuthorization": "/cosmwasm.wasm.v1.MsgMigrateContract",
|
|
664
|
+
"/cosmos.distribution.v1beta1.SetWithdrawAddressAuthorization": "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress"
|
|
665
|
+
};
|
|
666
|
+
var REVOKE_MSG_TYPE_URL_BY_STAKE_AUTH_TYPE = {
|
|
667
|
+
AUTHORIZATION_TYPE_DELEGATE: "/cosmos.staking.v1beta1.MsgDelegate",
|
|
668
|
+
"1": "/cosmos.staking.v1beta1.MsgDelegate",
|
|
669
|
+
AUTHORIZATION_TYPE_UNDELEGATE: "/cosmos.staking.v1beta1.MsgUndelegate",
|
|
670
|
+
"2": "/cosmos.staking.v1beta1.MsgUndelegate",
|
|
671
|
+
AUTHORIZATION_TYPE_REDELEGATE: "/cosmos.staking.v1beta1.MsgBeginRedelegate",
|
|
672
|
+
"3": "/cosmos.staking.v1beta1.MsgBeginRedelegate"
|
|
673
|
+
};
|
|
674
|
+
function getMsgTypeUrlForRevoke(authorizationTypeUrl, stakeAuthType) {
|
|
675
|
+
if (authorizationTypeUrl === STAKE_AUTHORIZATION_TYPE_URL) {
|
|
676
|
+
const key = String(stakeAuthType ?? "");
|
|
677
|
+
return REVOKE_MSG_TYPE_URL_BY_STAKE_AUTH_TYPE[key] ?? authorizationTypeUrl;
|
|
678
|
+
}
|
|
679
|
+
return REVOKE_MSG_TYPE_URL_BY_AUTHORIZATION[authorizationTypeUrl] ?? authorizationTypeUrl;
|
|
680
|
+
}
|
|
681
|
+
|
|
655
682
|
// src/grants/utils/authz.ts
|
|
656
683
|
init_contract_validation();
|
|
657
684
|
var InvalidContractGrantError = class extends Error {
|
|
@@ -1017,6 +1044,11 @@ var DaoDaoTreasuryStrategy = class {
|
|
|
1017
1044
|
throw new Error("Invalid indexer response: not an object");
|
|
1018
1045
|
}
|
|
1019
1046
|
const response = data;
|
|
1047
|
+
if (response.admin == null || typeof response.admin === "string" && response.admin.trim() === "") {
|
|
1048
|
+
throw new Error(
|
|
1049
|
+
"DaoDao indexer has no data for this treasury (admin is null, blank, or missing)"
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1020
1052
|
if (!response.grantConfigs || typeof response.grantConfigs !== "object") {
|
|
1021
1053
|
throw new Error("Invalid indexer response: missing grantConfigs");
|
|
1022
1054
|
}
|
|
@@ -2363,6 +2395,7 @@ exports.InvalidAllowanceError = InvalidAllowanceError;
|
|
|
2363
2395
|
exports.InvalidContractGrantError = InvalidContractGrantError;
|
|
2364
2396
|
exports.NumiaAccountStrategy = NumiaAccountStrategy;
|
|
2365
2397
|
exports.RpcAccountStrategy = RpcAccountStrategy;
|
|
2398
|
+
exports.STAKE_AUTHORIZATION_TYPE_URL = STAKE_AUTHORIZATION_TYPE_URL;
|
|
2366
2399
|
exports.SubqueryAccountStrategy = SubqueryAccountStrategy;
|
|
2367
2400
|
exports.accountStateReducer = accountStateReducer;
|
|
2368
2401
|
exports.buildGrantMessages = buildGrantMessages;
|
|
@@ -2390,6 +2423,7 @@ exports.generateTreasuryGrants = generateTreasuryGrants;
|
|
|
2390
2423
|
exports.getAccountInfoFromRestored = getAccountInfoFromRestored;
|
|
2391
2424
|
exports.getContractAddress = getContractAddress;
|
|
2392
2425
|
exports.getDomainAndProtocol = getDomainAndProtocol;
|
|
2426
|
+
exports.getMsgTypeUrlForRevoke = getMsgTypeUrlForRevoke;
|
|
2393
2427
|
exports.initiateRedirect = initiateRedirect;
|
|
2394
2428
|
exports.isContractGrantConfigValid = isContractGrantConfigValid;
|
|
2395
2429
|
exports.isDuplicateAuthenticator = isDuplicateAuthenticator;
|