Skip to content

Commit

Permalink
Merge pull request #123 from gemworks/auth-owned-pda
Browse files Browse the repository at this point in the history
withdraw any tokens from PDAs owned by vault authority
  • Loading branch information
ilmoi authored Jan 11, 2023
2 parents 7d665f9 + f6d51cd commit 8f7f12b
Show file tree
Hide file tree
Showing 19 changed files with 1,559 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/gem-bank/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"update:anchor": "yarn upgrade @project-serum/anchor --latest --check-files"
},
"dependencies": {
"@gemworks/gem-farm-ts": "^0.24.1",
"@gemworks/gem-farm-ts": "^0.24.2",
"@metaplex/js": "^4.9.0",
"@project-serum/anchor": "0.24.2",
"@solana/spl-token": "^0.1.8",
Expand Down
136 changes: 136 additions & 0 deletions app/gem-bank/public/gem_bank.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,67 @@
}
}
]
},
{
"name": "withdrawTokensAuth",
"accounts": [
{
"name": "bank",
"isMut": false,
"isSigner": false
},
{
"name": "vault",
"isMut": true,
"isSigner": false
},
{
"name": "owner",
"isMut": true,
"isSigner": true
},
{
"name": "authority",
"isMut": false,
"isSigner": false
},
{
"name": "vaultAta",
"isMut": true,
"isSigner": false
},
{
"name": "recipientAta",
"isMut": true,
"isSigner": false
},
{
"name": "mint",
"isMut": false,
"isSigner": false
},
{
"name": "tokenProgram",
"isMut": false,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
},
{
"name": "associatedTokenProgram",
"isMut": false,
"isSigner": false
},
{
"name": "rent",
"isMut": false,
"isSigner": false
}
],
"args": []
}
],
"accounts": [
Expand All @@ -463,6 +524,10 @@
},
{
"name": "bankManager",
"docs": [
"sole control over gem whitelist, un/locking the vaults, and bank flags",
"can update itself to another Pubkey"
],
"type": "publicKey"
},
{
Expand All @@ -471,18 +536,32 @@
},
{
"name": "whitelistedCreators",
"docs": [
"only gems allowed will be those that have EITHER a:",
"1) creator from this list"
],
"type": "u32"
},
{
"name": "whitelistedMints",
"docs": [
"OR",
"2) mint from this list"
],
"type": "u32"
},
{
"name": "vaultCount",
"docs": [
"total vault count registered with this bank"
],
"type": "u64"
},
{
"name": "reserved",
"docs": [
"reserved for future updates, has to be /8"
],
"type": {
"array": [
"u8",
Expand All @@ -495,27 +574,48 @@
},
{
"name": "GemDepositReceipt",
"docs": [
"GDR is necessary to locate all gem boxes for a given bank/vault",
"see fetchAllGdrPDAs() in TS client"
],
"type": {
"kind": "struct",
"fields": [
{
"name": "vault",
"docs": [
"each gem gox sits inside a single vault"
],
"type": "publicKey"
},
{
"name": "gemBoxAddress",
"docs": [
"the token account that actually holds the deposited gem(s)"
],
"type": "publicKey"
},
{
"name": "gemMint",
"docs": [
"the following is really stored for convenience, so we don't have to fetch gem account separately"
],
"type": "publicKey"
},
{
"name": "gemCount",
"docs": [
"number of gems deposited into this GDR",
"in theory, if each gem is actually an NFT this number would be 1",
"but the vault is generic enough to support fungible tokens as well, so this can be >1"
],
"type": "u64"
},
{
"name": "reserved",
"docs": [
"reserved for future updates, has to be /8"
],
"type": {
"array": [
"u8",
Expand Down Expand Up @@ -545,18 +645,32 @@
"fields": [
{
"name": "bank",
"docs": [
"each vault is registered with a single bank, used for indexing"
],
"type": "publicKey"
},
{
"name": "owner",
"docs": [
"responsible for signing deposits / withdrawals into the vault",
"(!) NOTE: does NOT un/lock the vault - the bank manager does that",
"can update itself to another Pubkey"
],
"type": "publicKey"
},
{
"name": "creator",
"docs": [
"pubkey used to create the vault, baked into vault's PDA - NOT CHANGEABLE"
],
"type": "publicKey"
},
{
"name": "authority",
"docs": [
"signs off on any token transfers out of the gem boxes controlled by the vault"
],
"type": "publicKey"
},
{
Expand All @@ -574,6 +688,9 @@
},
{
"name": "locked",
"docs": [
"when the vault is locked, no gems can move in/out of it"
],
"type": "bool"
},
{
Expand All @@ -587,18 +704,31 @@
},
{
"name": "gemBoxCount",
"docs": [
"total number of token mints stored in the vault (gem box per mint)"
],
"type": "u64"
},
{
"name": "gemCount",
"docs": [
"gem_boxes can store >1 token, see detailed explanation on GDR"
],
"type": "u64"
},
{
"name": "rarityPoints",
"docs": [
"each gem has a rarity of 1 if not specified",
"thus worst case, when rarities aren't enabled, this is == gem_count"
],
"type": "u64"
},
{
"name": "reserved",
"docs": [
"reserved for future updates, has to be /8"
],
"type": {
"array": [
"u8",
Expand All @@ -611,6 +741,12 @@
},
{
"name": "WhitelistProof",
"docs": [
"whitelists are used to control what gems can/can't go into the vault",
"currently 2 types of vault lists are supported: by mint and by creator",
"if the whitelist PDA exists, then the mint/creator is considered accepted",
"if at least 1 whitelist PDA exists total, then all deposit attempts will start getting checked"
],
"type": {
"kind": "struct",
"fields": [
Expand Down
8 changes: 4 additions & 4 deletions app/gem-bank/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,10 @@
dependencies:
purgecss "^3.1.3"

"@gemworks/gem-farm-ts@^0.24.1":
version "0.24.1"
resolved "https://registry.yarnpkg.com/@gemworks/gem-farm-ts/-/gem-farm-ts-0.24.1.tgz#2497f80affa54121ffb04da766791ecd1ea7cf0b"
integrity sha512-/CnX1CcE4m/FDD/slixCs9RXox3ZUpnvs1ccHPlSbSmRZpbOMltcUQy6xqi7i0zITzSI90i0iXfCuRnV2CwGiw==
"@gemworks/gem-farm-ts@^0.24.2":
version "0.24.2"
resolved "https://registry.yarnpkg.com/@gemworks/gem-farm-ts/-/gem-farm-ts-0.24.2.tgz#f8380dcba804079b9bc50b3aa1e62bbfc88c943c"
integrity sha512-bopxvI3/gi8e9IbMt+lcxXMduXehgQ39gufAnR4lM3Q6J7J+u3tLkHoFPvyMOd2dGvZxXPAMFE73NLZYxQaMoQ==
dependencies:
"@metaplex-foundation/mpl-token-metadata" "^0.0.2"
"@metaplex/js" "^4.9.0"
Expand Down
2 changes: 1 addition & 1 deletion app/gem-farm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"update:anchor": "yarn upgrade @project-serum/anchor --latest --check-files"
},
"dependencies": {
"@gemworks/gem-farm-ts": "^0.24.1",
"@gemworks/gem-farm-ts": "^0.24.2",
"@metaplex/js": "^4.9.0",
"@project-serum/anchor": "0.24.2",
"@solana/spl-token": "^0.1.8",
Expand Down
Loading

0 comments on commit 8f7f12b

Please sign in to comment.