-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Add daoUpdateAction encoders and decoders (#289)
- Loading branch information
1 parent
4a927a2
commit bf3e275
Showing
9 changed files
with
243 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
modules/client/examples/05-encoders-decoders/16-dao-update.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* MARKDOWN | ||
--- | ||
title: Update a DAO | ||
--- | ||
## Generate a DAO Update action | ||
Given a DAO address, the previous version and the new DAO Factory address, it generates the actions to update a DAO. | ||
### Encoding | ||
*/ | ||
|
||
import { | ||
Client, | ||
DaoUpdateDecodedParams, | ||
DaoUpdateParams, | ||
} from "@aragon/sdk-client"; | ||
import { | ||
DaoAction, | ||
LIVE_CONTRACTS, | ||
} from "@aragon/sdk-client-common"; | ||
import { context } from "../index"; | ||
|
||
// Instantiates an Aragon OSx SDK client. | ||
const client: Client = new Client(context); | ||
|
||
const daoUpdateParams: DaoUpdateParams = { | ||
previousVersion: [1, 0, 0], | ||
daoFactoryAddress: LIVE_CONTRACTS["1.3.0"].base.daoFactoryAddress, // if not specified it will use the latest version in the context network | ||
initData: new Uint8Array([12, 34, 45, 56]), // data needed to update specified, empty by default | ||
}; | ||
|
||
const daoAddressOrEns: string = "0x123123123123123123123123123123123123"; // "my-dao.eth" | ||
|
||
const actions: DaoAction = await client.encoding.daoUpdateAction( | ||
daoAddressOrEns, | ||
daoUpdateParams, | ||
); | ||
console.log(actions); | ||
|
||
/* MARKDOWN | ||
```json | ||
{ | ||
to: "0x123123123...", | ||
value: 0n, | ||
data: Uint8Array[12,34,45...] | ||
}, | ||
``` | ||
### Decoding | ||
*/ | ||
|
||
// Decodes the apply update action for a Multisig plugin. | ||
const decodedParams: DaoUpdateDecodedParams = client.decoding | ||
.daoUpdateAction(actions[1].data); | ||
console.log({ decodedParams }); | ||
|
||
/* MARKDOWN | ||
Returns: | ||
```json | ||
{ decodedParams: | ||
{ | ||
previousVersion: [1, 0, 0], | ||
implementationAddress: "0x123123123...", // DAO base implementation address | ||
initData: Uint8Array[12,34,45...] | ||
} | ||
} | ||
``` | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.