-
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 support nft deposits and withdrawals (#259)
* add erc721 support for deposits and withdraw * update changelog * add encoding and decoding tests * add use of openzeppelin abis * fix comments * update and simply deposit function * update yarn.lock and remove unused error class * update erc20 abi and deposit function * add abstactions to class
- Loading branch information
1 parent
f29d8de
commit 1b4f360
Showing
27 changed files
with
421 additions
and
202 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
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,69 @@ | ||
/* MARKDOWN | ||
--- | ||
title: Deposit ERC-721 | ||
--- | ||
### Deposit ERC-721 Tokens to a DAO | ||
Deposits ERC-721 tokens to a DAO. | ||
- Similar to the ERC20 deposit flow | ||
- The `tokenAddress` field is required. This is the contract address of the ERC-721 token. | ||
- TokenId is required. This is the token ID of the ERC-721 token. | ||
- Calls the safeTransferFrom function of the ERC-721 token contract. | ||
*/ | ||
|
||
import { | ||
Client, | ||
DaoDepositSteps, | ||
DepositParams, | ||
SetAllowanceSteps, | ||
} from "@aragon/sdk-client"; | ||
import { GasFeeEstimation, TokenType } from "@aragon/sdk-client-common"; | ||
import { context } from "../index"; | ||
|
||
// Instantiate the general purpose client from the Aragon OSx SDK context. | ||
const client: Client = new Client(context); | ||
|
||
const depositParams: DepositParams = { | ||
daoAddressOrEns: "0x1234567890123456789012345678901234567890", // my-dao.dao.eth | ||
tokenAddress: "0x1234567890123456789012345678901234567890", // token contract adddress | ||
type: TokenType.ERC721, // "erc721" for ERC721 token | ||
tokenId: BigInt(1), // token ID of the ERC-721 token | ||
}; | ||
|
||
// Estimate how much gas the transaction will cost. | ||
const estimatedGas: GasFeeEstimation = await client.estimation.deposit( | ||
depositParams, | ||
); | ||
console.log({ avg: estimatedGas.average, max: estimatedGas.max }); | ||
|
||
// Deposit the ERC721 tokens. | ||
const steps = client.methods.deposit(depositParams); | ||
for await (const step of steps) { | ||
try { | ||
switch (step.key) { | ||
case DaoDepositSteps.DEPOSITING: | ||
console.log({ depositingTxHash: step.txHash }); | ||
break; | ||
case DaoDepositSteps.DONE: | ||
console.log({ tokenId: step.tokenId }); | ||
break; | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
|
||
/* MARKDOWN | ||
Returns: | ||
```tsx | ||
{ | ||
depositingTxHash: "0xb1c14a49...3e8620b0f5832d61c" | ||
} | ||
{ | ||
tokenId: 1n | ||
} | ||
``` | ||
*/ | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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.