diff --git a/Cargo.lock b/Cargo.lock index 877a9a5..a55e62f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -790,9 +790,9 @@ dependencies = [ [[package]] name = "codama" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf2f908673e3177aa1c6546b61fac36874efba6754ffa2b6082f676bd8fa3e0" +checksum = "f6b12c0b52a61261c057e4a786f30d535d49f545b32fb9757cdc4945b05dc907" dependencies = [ "codama-errors", "codama-korok-plugins", @@ -806,9 +806,9 @@ dependencies = [ [[package]] name = "codama-attributes" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce088c3f23ad6a6f9b69da81751c87212da2c2195f1b3e391619c3b626473c25" +checksum = "0530aae728a7c8993839930c7c923f51a32fd432ddc2fbaf127e7e85fd96c734" dependencies = [ "codama-errors", "codama-nodes", @@ -821,9 +821,9 @@ dependencies = [ [[package]] name = "codama-errors" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6485d98de3a1cfd25975cc5afca9c8e03da3ae85c0e4ef1ad818579f7fdc640a" +checksum = "3b1ccf69a1f4e56f08250dd09d285990abe0e94467d14ab791d291511f6a0aee" dependencies = [ "cargo_toml", "proc-macro2", @@ -834,9 +834,9 @@ dependencies = [ [[package]] name = "codama-korok-plugins" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c0899cf03caae88577f4423bebb84659778fca4db1caf4f9dd777ac16f8406" +checksum = "2bb70eaf4a37dea5ddf75ca14afcd5f62543acf9d0f8e98f9a95cd40d546d3a6" dependencies = [ "codama-errors", "codama-korok-visitors", @@ -845,9 +845,9 @@ dependencies = [ [[package]] name = "codama-korok-visitors" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b3b1d119c0b247a4746f963bb05e7470d7a3729da8f4040144eea4745e73ac1" +checksum = "81c5f5ba09d746e44d5a1d7381d62bf984b1e9a5dd6cfd931c667d33673fd26b" dependencies = [ "cargo_toml", "codama-attributes", @@ -861,9 +861,9 @@ dependencies = [ [[package]] name = "codama-koroks" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb43f91eef59c2e4ca8b7c9f54026a5f43f6f3b3c0505ed77be1abd900525ce" +checksum = "de65e986ed08d93abf355ef62b31de9a6e4c78157590c375c6d39bd98640e548" dependencies = [ "codama-attributes", "codama-errors", @@ -877,9 +877,9 @@ dependencies = [ [[package]] name = "codama-macros" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f20101421d0bc92133bdfb99be7585196e6313c8665bbdb5830701ab7ca85ee" +checksum = "afdf314b062a4a0c73132d8ba18d98904335a102093417ea28c38fced5e864c0" dependencies = [ "codama-attributes", "codama-errors", @@ -892,9 +892,9 @@ dependencies = [ [[package]] name = "codama-nodes" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b4a10746031fb835ee90b0f1d67844de91e938d93df6167129325bb886a5da" +checksum = "b7d682e171abf115c184ddc39a096bb743cdbcdd7f9940f6104a642a0f5afab1" dependencies = [ "codama-errors", "codama-nodes-derive", @@ -905,9 +905,9 @@ dependencies = [ [[package]] name = "codama-nodes-derive" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e195f4c7b6a93180a3eb59ba53016d4ea4bbef212f78fa6a04835fe244cb3da1" +checksum = "d21379376d3e6ac5c04af64bfd817c8d48246e8040633370d633cdae047bea7e" dependencies = [ "codama-errors", "codama-syn-helpers", @@ -919,9 +919,9 @@ dependencies = [ [[package]] name = "codama-stores" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56bd0a298e94a566dbd3451d1613ba1f7290bfbaa38e66b8ebd0d3688824bd59" +checksum = "c2b259fad9bbd557d05f7aea51c26cc5ab8e51b4c367976121c8de5db246c849" dependencies = [ "cargo_toml", "codama-errors", @@ -931,9 +931,9 @@ dependencies = [ [[package]] name = "codama-syn-helpers" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dd908283642bba89c720b5f58d43746e7a3506a960b90357ce64e160381374" +checksum = "f33123a6977e8eed56c9bc83439a62e556bdffff9c211e71e42e0a4e20fe5232" dependencies = [ "codama-errors", "derive_more", diff --git a/Cargo.toml b/Cargo.toml index 4c040f9..ffe9685 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [ ] } [workspace.dependencies] -codama = "^0.7.2" +codama = "^0.7.4" serde_json = "^1.0.145" const-crypto = "^0.3.0" pinocchio = "^0.10.1" diff --git a/idl/escrow_program.json b/idl/escrow_program.json index 6a8a79e..32f7a65 100644 --- a/idl/escrow_program.json +++ b/idl/escrow_program.json @@ -1,11 +1,76 @@ { - "additionalPrograms": [], + "additionalPrograms": [ + { + "accounts": [], + "definedTypes": [], + "errors": [], + "instructions": [], + "kind": "programNode", + "name": "associatedToken", + "pdas": [ + { + "kind": "pdaNode", + "name": "associatedToken", + "seeds": [ + { + "kind": "variablePdaSeedNode", + "name": "owner", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "tokenProgram", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "mint", + "type": { + "kind": "publicKeyTypeNode" + } + } + ] + } + ], + "publicKey": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", + "version": "" + } + ], "kind": "rootNode", "program": { "accounts": [ + { + "data": { + "fields": [], + "kind": "structTypeNode" + }, + "kind": "accountNode", + "name": "eventAuthority", + "pda": { + "kind": "pdaLinkNode", + "name": "eventAuthority" + } + }, { "data": { "fields": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 3 + }, + "kind": "structFieldTypeNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + }, { "kind": "structFieldTypeNode", "name": "bump", @@ -18,12 +83,36 @@ ], "kind": "structTypeNode" }, + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], "kind": "accountNode", - "name": "allowedMint" + "name": "allowedMint", + "pda": { + "kind": "pdaLinkNode", + "name": "allowedMint" + } }, { "data": { "fields": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 0 + }, + "kind": "structFieldTypeNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + }, { "kind": "structFieldTypeNode", "name": "bump", @@ -50,12 +139,36 @@ ], "kind": "structTypeNode" }, + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], "kind": "accountNode", - "name": "escrow" + "name": "escrow", + "pda": { + "kind": "pdaLinkNode", + "name": "escrow" + } }, { "data": { "fields": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 1 + }, + "kind": "structFieldTypeNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + }, { "kind": "structFieldTypeNode", "name": "bump", @@ -77,12 +190,36 @@ ], "kind": "structTypeNode" }, + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], "kind": "accountNode", - "name": "escrowExtensionsHeader" + "name": "escrowExtensionsHeader", + "pda": { + "kind": "pdaLinkNode", + "name": "extensions" + } }, { "data": { "fields": [ + { + "defaultValue": { + "kind": "numberValueNode", + "number": 2 + }, + "kind": "structFieldTypeNode", + "name": "discriminator", + "type": { + "endian": "le", + "format": "u8", + "kind": "numberTypeNode" + } + }, { "kind": "structFieldTypeNode", "name": "bump", @@ -157,8 +294,19 @@ ], "kind": "structTypeNode" }, + "discriminators": [ + { + "kind": "fieldDiscriminatorNode", + "name": "discriminator", + "offset": 0 + } + ], "kind": "accountNode", - "name": "receipt" + "name": "receipt", + "pda": { + "kind": "pdaLinkNode", + "name": "receipt" + } } ], "definedTypes": [ @@ -573,6 +721,23 @@ "name": "escrowSeed" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "escrow" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrowSeed", + "value": { + "kind": "accountValueNode", + "name": "escrowSeed" + } + } + ] + }, "docs": [ "Escrow PDA account to be created" ], @@ -582,6 +747,10 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + }, "docs": [ "System program" ], @@ -591,6 +760,10 @@ "name": "systemProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -600,6 +773,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -625,6 +802,10 @@ } }, { + "defaultValue": { + "kind": "accountBumpValueNode", + "name": "escrow" + }, "kind": "instructionArgumentNode", "name": "bump", "type": { @@ -674,6 +855,23 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "extensions" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + } + ] + }, "docs": [ "Extensions PDA account to store timelock config" ], @@ -683,6 +881,10 @@ "name": "extensions" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + }, "docs": [ "System program" ], @@ -692,6 +894,10 @@ "name": "systemProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -701,6 +907,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -726,6 +936,10 @@ } }, { + "defaultValue": { + "kind": "accountBumpValueNode", + "name": "extensions" + }, "kind": "instructionArgumentNode", "name": "extensionsBump", "type": { @@ -784,6 +998,23 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "extensions" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + } + ] + }, "docs": [ "Extensions PDA account to store hook config" ], @@ -793,6 +1024,10 @@ "name": "extensions" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + }, "docs": [ "System program" ], @@ -802,6 +1037,10 @@ "name": "systemProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -811,6 +1050,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -836,6 +1079,10 @@ } }, { + "defaultValue": { + "kind": "accountBumpValueNode", + "name": "extensions" + }, "kind": "instructionArgumentNode", "name": "extensionsBump", "type": { @@ -892,6 +1139,31 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "allowedMint" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + } + ] + }, "docs": [ "Allowed mint PDA proving this mint is permitted" ], @@ -910,6 +1182,47 @@ "name": "receiptSeed" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "receipt" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "depositor", + "value": { + "kind": "accountValueNode", + "name": "depositor" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "receiptSeed", + "value": { + "kind": "accountValueNode", + "name": "receiptSeed" + } + } + ] + }, "docs": [ "Deposit receipt PDA to be created" ], @@ -919,6 +1232,43 @@ "name": "receipt" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "associatedToken", + "program": { + "kind": "programLinkNode", + "name": "associatedToken" + } + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "owner", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "tokenProgram", + "value": { + "kind": "accountValueNode", + "name": "tokenProgram" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + } + ] + }, "docs": [ "Escrow vault token account to receive tokens" ], @@ -928,6 +1278,43 @@ "name": "vault" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "associatedToken", + "program": { + "kind": "programLinkNode", + "name": "associatedToken" + } + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "owner", + "value": { + "kind": "accountValueNode", + "name": "depositor" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "tokenProgram", + "value": { + "kind": "accountValueNode", + "name": "tokenProgram" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + } + ] + }, "docs": [ "Depositor's token account to transfer from" ], @@ -946,6 +1333,10 @@ "name": "mint" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, "docs": [ "SPL Token program" ], @@ -955,6 +1346,10 @@ "name": "tokenProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + }, "docs": [ "System program" ], @@ -964,6 +1359,10 @@ "name": "systemProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -973,6 +1372,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -982,6 +1385,23 @@ "name": "escrowProgram" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "extensions" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + } + ] + }, "docs": [ "Extensions PDA for escrow configuration" ], @@ -1007,6 +1427,10 @@ } }, { + "defaultValue": { + "kind": "accountBumpValueNode", + "name": "receipt" + }, "kind": "instructionArgumentNode", "name": "bump", "type": { @@ -1065,6 +1489,10 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -1074,6 +1502,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -1139,6 +1571,23 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "extensions" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + } + ] + }, "docs": [ "Extensions PDA for escrow configuration" ], @@ -1157,6 +1606,43 @@ "name": "receipt" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "associatedToken", + "program": { + "kind": "programLinkNode", + "name": "associatedToken" + } + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "owner", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "tokenProgram", + "value": { + "kind": "accountValueNode", + "name": "tokenProgram" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + } + ] + }, "docs": [ "Escrow vault token account to transfer from" ], @@ -1166,6 +1652,43 @@ "name": "vault" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "associatedToken", + "program": { + "kind": "programLinkNode", + "name": "associatedToken" + } + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "owner", + "value": { + "kind": "accountValueNode", + "name": "withdrawer" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "tokenProgram", + "value": { + "kind": "accountValueNode", + "name": "tokenProgram" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + } + ] + }, "docs": [ "Withdrawer's token account to receive tokens" ], @@ -1184,6 +1707,10 @@ "name": "mint" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, "docs": [ "SPL Token program" ], @@ -1193,6 +1720,10 @@ "name": "tokenProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + }, "docs": [ "System program" ], @@ -1202,6 +1733,10 @@ "name": "systemProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -1211,6 +1746,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -1276,6 +1815,23 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "extensions" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + } + ] + }, "docs": [ "Extensions PDA for escrow configuration" ], @@ -1294,6 +1850,31 @@ "name": "mint" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "allowedMint" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + } + ] + }, "docs": [ "Allowed mint PDA to be created" ], @@ -1303,6 +1884,43 @@ "name": "allowedMint" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "associatedToken", + "program": { + "kind": "programLinkNode", + "name": "associatedToken" + } + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "owner", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "tokenProgram", + "value": { + "kind": "accountValueNode", + "name": "tokenProgram" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + } + ] + }, "docs": [ "Escrow vault ATA to be created for this mint" ], @@ -1312,6 +1930,10 @@ "name": "vault" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, "docs": [ "SPL Token program" ], @@ -1321,6 +1943,10 @@ "name": "tokenProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, "docs": [ "Associated Token program for vault creation" ], @@ -1330,6 +1956,10 @@ "name": "associatedTokenProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + }, "docs": [ "System program" ], @@ -1339,6 +1969,10 @@ "name": "systemProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -1348,6 +1982,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -1373,6 +2011,10 @@ } }, { + "defaultValue": { + "kind": "accountBumpValueNode", + "name": "allowedMint" + }, "kind": "instructionArgumentNode", "name": "bump", "type": { @@ -1431,6 +2073,31 @@ "name": "mint" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "allowedMint" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + }, + { + "kind": "pdaSeedValueNode", + "name": "mint", + "value": { + "kind": "accountValueNode", + "name": "mint" + } + } + ] + }, "docs": [ "Allowed mint PDA to be closed" ], @@ -1440,6 +2107,10 @@ "name": "allowedMint" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, "docs": [ "SPL Token program" ], @@ -1449,6 +2120,10 @@ "name": "tokenProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -1458,6 +2133,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -1523,6 +2202,23 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "extensions" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + } + ] + }, "docs": [ "Extensions PDA account to store blocked extensions" ], @@ -1532,6 +2228,10 @@ "name": "extensions" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + }, "docs": [ "System program" ], @@ -1541,6 +2241,10 @@ "name": "systemProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "docs": [ "Event authority PDA for CPI event emission" ], @@ -1550,6 +2254,10 @@ "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "docs": [ "Escrow program for CPI event emission" ], @@ -1575,6 +2283,10 @@ } }, { + "defaultValue": { + "kind": "accountBumpValueNode", + "name": "extensions" + }, "kind": "instructionArgumentNode", "name": "extensionsBump", "type": { @@ -1630,24 +2342,53 @@ "name": "escrow" }, { + "defaultValue": { + "kind": "pdaValueNode", + "pda": { + "kind": "pdaLinkNode", + "name": "extensions" + }, + "seeds": [ + { + "kind": "pdaSeedValueNode", + "name": "escrow", + "value": { + "kind": "accountValueNode", + "name": "escrow" + } + } + ] + }, "isSigner": false, "isWritable": true, "kind": "instructionAccountNode", "name": "extensions" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "11111111111111111111111111111111" + }, "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "systemProgram" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M" + }, "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", "name": "eventAuthority" }, { + "defaultValue": { + "kind": "publicKeyValueNode", + "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg" + }, "isSigner": false, "isWritable": false, "kind": "instructionAccountNode", @@ -1670,6 +2411,10 @@ } }, { + "defaultValue": { + "kind": "accountBumpValueNode", + "name": "extensions" + }, "kind": "instructionArgumentNode", "name": "extensionsBump", "type": { @@ -1688,49 +2433,153 @@ ], "kind": "instructionNode", "name": "setArbiter" + } + ], + "kind": "programNode", + "name": "escrowProgram", + "pdas": [ + { + "kind": "pdaNode", + "name": "eventAuthority", + "seeds": [ + { + "kind": "constantPdaSeedNode", + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" + }, + "value": { + "kind": "stringValueNode", + "string": "event_authority" + } + } + ] }, { - "accounts": [ + "kind": "pdaNode", + "name": "allowedMint", + "seeds": [ { - "docs": [ - "Event authority PDA that must sign via CPI" - ], - "isSigner": true, - "isWritable": false, - "kind": "instructionAccountNode", - "name": "eventAuthority" + "kind": "constantPdaSeedNode", + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" + }, + "value": { + "kind": "stringValueNode", + "string": "allowed_mint" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "escrow", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "mint", + "type": { + "kind": "publicKeyTypeNode" + } } - ], - "arguments": [ + ] + }, + { + "kind": "pdaNode", + "name": "escrow", + "seeds": [ { - "defaultValue": { - "kind": "numberValueNode", - "number": 228 + "kind": "constantPdaSeedNode", + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" }, - "defaultValueStrategy": "omitted", - "kind": "instructionArgumentNode", - "name": "discriminator", + "value": { + "kind": "stringValueNode", + "string": "escrow" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "escrowSeed", "type": { - "endian": "le", - "format": "u8", - "kind": "numberTypeNode" + "kind": "publicKeyTypeNode" } } - ], - "discriminators": [ + ] + }, + { + "kind": "pdaNode", + "name": "extensions", + "seeds": [ { - "kind": "fieldDiscriminatorNode", - "name": "discriminator", - "offset": 0 + "kind": "constantPdaSeedNode", + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" + }, + "value": { + "kind": "stringValueNode", + "string": "extensions" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "escrow", + "type": { + "kind": "publicKeyTypeNode" + } } - ], - "kind": "instructionNode", - "name": "emitEvent" + ] + }, + { + "kind": "pdaNode", + "name": "receipt", + "seeds": [ + { + "kind": "constantPdaSeedNode", + "type": { + "encoding": "utf8", + "kind": "stringTypeNode" + }, + "value": { + "kind": "stringValueNode", + "string": "receipt" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "escrow", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "depositor", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "mint", + "type": { + "kind": "publicKeyTypeNode" + } + }, + { + "kind": "variablePdaSeedNode", + "name": "receiptSeed", + "type": { + "kind": "publicKeyTypeNode" + } + } + ] } ], - "kind": "programNode", - "name": "escrowProgram", - "pdas": [], "publicKey": "Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg", "version": "0.0.1" }, diff --git a/justfile b/justfile index 32840ec..beaf7a3 100644 --- a/justfile +++ b/justfile @@ -35,6 +35,7 @@ check: cd program && cargo check --features idl pnpm run format:check pnpm lint + pnpm run typecheck # Run unit tests unit-test: diff --git a/package.json b/package.json index 6095f56..685a201 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint .", - "lint:fix": "eslint . --fix" + "lint:fix": "eslint . --fix", + "typecheck": "cd clients/typescript && tsc --noEmit" }, "devDependencies": { "@codama/nodes-from-anchor": "^1.3.8", diff --git a/program/src/instructions/definition.rs b/program/src/instructions/definition.rs index 7b2433b..d3bd480 100644 --- a/program/src/instructions/definition.rs +++ b/program/src/instructions/definition.rs @@ -10,25 +10,53 @@ pub enum EscrowProgramInstruction { #[codama(account(name = "payer", docs = "Pays for escrow account creation", signer, writable))] #[codama(account(name = "admin", docs = "Admin authority for the escrow", signer))] #[codama(account(name = "escrow_seed", docs = "Random keypair seed for escrow PDA derivation", signer))] - #[codama(account(name = "escrow", docs = "Escrow PDA account to be created", writable))] - #[codama(account(name = "system_program", docs = "System program"))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] + #[codama(account( + name = "escrow", + docs = "Escrow PDA account to be created", + writable, + default_value = pda("escrow", [seed("escrowSeed", account("escrowSeed"))]) + ))] + #[codama(account(name = "system_program", docs = "System program", default_value = program("system")))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] CreatesEscrow { /// Bump for the escrow PDA + #[codama(default_value = account_bump("escrow"))] bump: u8, } = 0, /// Add timelock extension to an escrow. #[codama(account(name = "payer", docs = "Pays for extensions account creation", signer, writable))] #[codama(account(name = "admin", docs = "Admin authority for the escrow", signer))] - #[codama(account(name = "escrow", docs = "Escrow account to add timelock to"))] - #[codama(account(name = "extensions", docs = "Extensions PDA account to store timelock config", writable))] - #[codama(account(name = "system_program", docs = "System program"))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] + #[codama(account(name = "escrow", docs = "Escrow account to add timelock to",))] + #[codama(account( + name = "extensions", + docs = "Extensions PDA account to store timelock config", + writable, + default_value = pda("extensions", [seed("escrow", account("escrow"))]) + ))] + #[codama(account(name = "system_program", docs = "System program", default_value = program("system")))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] AddTimelock { /// Bump for extensions PDA + #[codama(default_value = account_bump("extensions"))] extensions_bump: u8, /// Lock duration in seconds from deposit lock_duration: u64, @@ -38,12 +66,26 @@ pub enum EscrowProgramInstruction { #[codama(account(name = "payer", docs = "Pays for extensions account creation", signer, writable))] #[codama(account(name = "admin", docs = "Admin authority for the escrow", signer))] #[codama(account(name = "escrow", docs = "Escrow account to set hook on"))] - #[codama(account(name = "extensions", docs = "Extensions PDA account to store hook config", writable))] - #[codama(account(name = "system_program", docs = "System program"))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] + #[codama(account( + name = "extensions", + docs = "Extensions PDA account to store hook config", + writable, + default_value = pda("extensions", [seed("escrow", account("escrow"))]) + ))] + #[codama(account(name = "system_program", docs = "System program", default_value = program("system")))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] SetHook { /// Bump for extensions PDA + #[codama(default_value = account_bump("extensions"))] extensions_bump: u8, /// Hook program address hook_program: Address, @@ -53,23 +95,56 @@ pub enum EscrowProgramInstruction { #[codama(account(name = "payer", docs = "Pays for receipt account creation", signer, writable))] #[codama(account(name = "depositor", docs = "Authority depositing tokens", signer))] #[codama(account(name = "escrow", docs = "Escrow account to deposit into"))] - #[codama(account(name = "allowed_mint", docs = "Allowed mint PDA proving this mint is permitted"))] + #[codama(account( + name = "allowed_mint", + docs = "Allowed mint PDA proving this mint is permitted", + default_value = pda("allowedMint", [seed("escrow", account("escrow")), seed("mint", account("mint"))]) + ))] #[codama(account(name = "receipt_seed", docs = "Random keypair seed for receipt PDA derivation", signer))] - #[codama(account(name = "receipt", docs = "Deposit receipt PDA to be created", writable))] - #[codama(account(name = "vault", docs = "Escrow vault token account to receive tokens", writable))] + #[codama(account( + name = "receipt", + docs = "Deposit receipt PDA to be created", + writable, + default_value = pda("receipt", [ + seed("escrow", account("escrow")), + seed("depositor", account("depositor")), + seed("mint", account("mint")), + seed("receiptSeed", account("receiptSeed")) + ]) + ))] + #[codama(account( + name = "vault", + docs = "Escrow vault token account to receive tokens", + writable, + default_value = pda("associatedToken", program = "associatedToken", [seed("owner", account("escrow")), seed("tokenProgram", account("tokenProgram")), seed("mint", account("mint"))]) + ))] #[codama(account( name = "depositor_token_account", docs = "Depositor's token account to transfer from", - writable + writable, + default_value = pda("associatedToken", program = "associatedToken", [seed("owner", account("depositor")), seed("tokenProgram", account("tokenProgram")), seed("mint", account("mint"))]) ))] #[codama(account(name = "mint", docs = "Token mint of the deposited tokens"))] - #[codama(account(name = "token_program", docs = "SPL Token program"))] - #[codama(account(name = "system_program", docs = "System program"))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] - #[codama(account(name = "extensions", docs = "Extensions PDA for escrow configuration"))] + #[codama(account(name = "token_program", docs = "SPL Token program", default_value = program("token")))] + #[codama(account(name = "system_program", docs = "System program", default_value = program("system")))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] + #[codama(account( + name = "extensions", + docs = "Extensions PDA for escrow configuration", + default_value = pda("extensions", [seed("escrow", account("escrow"))]) + ))] Deposit { /// Bump for the deposit receipt PDA + #[codama(default_value = account_bump("receipt"))] bump: u8, /// Amount of tokens to deposit amount: u64, @@ -79,27 +154,53 @@ pub enum EscrowProgramInstruction { #[codama(account(name = "admin", docs = "Current admin authority for the escrow", signer))] #[codama(account(name = "new_admin", docs = "New admin authority to transfer ownership to", signer))] #[codama(account(name = "escrow", docs = "Escrow account to update admin on", writable))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] UpdateAdmin {} = 4, /// Withdraw tokens from an escrow vault back to the original depositor. #[codama(account(name = "rent_recipient", docs = "Receives rent from closed receipt account", writable))] #[codama(account(name = "withdrawer", docs = "Authority withdrawing tokens", signer))] #[codama(account(name = "escrow", docs = "Escrow account to withdraw from"))] - #[codama(account(name = "extensions", docs = "Extensions PDA for escrow configuration"))] + #[codama(account( + name = "extensions", + docs = "Extensions PDA for escrow configuration", + default_value = pda("extensions", [seed("escrow", account("escrow"))]) + ))] #[codama(account(name = "receipt", docs = "Deposit receipt to close upon withdrawal", writable))] - #[codama(account(name = "vault", docs = "Escrow vault token account to transfer from", writable))] + #[codama(account( + name = "vault", + docs = "Escrow vault token account to transfer from", + writable, + default_value = pda("associatedToken", program = "associatedToken", [seed("owner", account("escrow")), seed("tokenProgram", account("tokenProgram")), seed("mint", account("mint"))]) + ))] #[codama(account( name = "withdrawer_token_account", docs = "Withdrawer's token account to receive tokens", - writable + writable, + default_value = pda("associatedToken", program = "associatedToken", [seed("owner", account("withdrawer")), seed("tokenProgram", account("tokenProgram")), seed("mint", account("mint"))]) ))] #[codama(account(name = "mint", docs = "Token mint of the withdrawn tokens"))] - #[codama(account(name = "token_program", docs = "SPL Token program"))] - #[codama(account(name = "system_program", docs = "System program"))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] + #[codama(account(name = "token_program", docs = "SPL Token program", default_value = program("token")))] + #[codama(account(name = "system_program", docs = "System program", default_value = program("system")))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] Withdraw {} = 5, /// Allow a token mint for deposits into an escrow. @@ -107,17 +208,44 @@ pub enum EscrowProgramInstruction { #[codama(account(name = "payer", docs = "Pays for allowed mint and vault account creation", signer, writable))] #[codama(account(name = "admin", docs = "Admin authority for the escrow", signer))] #[codama(account(name = "escrow", docs = "Escrow account to allow mint on"))] - #[codama(account(name = "escrow_extensions", docs = "Extensions PDA for escrow configuration"))] + #[codama(account( + name = "escrow_extensions", + docs = "Extensions PDA for escrow configuration", + default_value = pda("extensions", [seed("escrow", account("escrow"))]) + ))] #[codama(account(name = "mint", docs = "Token mint to allow for deposits"))] - #[codama(account(name = "allowed_mint", docs = "Allowed mint PDA to be created", writable))] - #[codama(account(name = "vault", docs = "Escrow vault ATA to be created for this mint", writable))] - #[codama(account(name = "token_program", docs = "SPL Token program"))] - #[codama(account(name = "associated_token_program", docs = "Associated Token program for vault creation"))] - #[codama(account(name = "system_program", docs = "System program"))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] + #[codama(account( + name = "allowed_mint", + docs = "Allowed mint PDA to be created", + writable, + default_value = pda("allowedMint", [seed("escrow", account("escrow")), seed("mint", account("mint"))]) + ))] + #[codama(account( + name = "vault", + docs = "Escrow vault ATA to be created for this mint", + writable, + default_value = pda("associatedToken", program = "associatedToken", [seed("owner", account("escrow")), seed("tokenProgram", account("tokenProgram")), seed("mint", account("mint"))]) + ))] + #[codama(account(name = "token_program", docs = "SPL Token program", default_value = program("token")))] + #[codama(account( + name = "associated_token_program", + docs = "Associated Token program for vault creation", + default_value = program("associated-token") + ))] + #[codama(account(name = "system_program", docs = "System program", default_value = program("system")))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] AllowMint { /// Bump for the allowed_mint PDA + #[codama(default_value = account_bump("allowedMint"))] bump: u8, } = 6, @@ -126,22 +254,49 @@ pub enum EscrowProgramInstruction { #[codama(account(name = "rent_recipient", docs = "Receives rent from closed allowed mint account", writable))] #[codama(account(name = "escrow", docs = "Escrow account to block mint on"))] #[codama(account(name = "mint", docs = "Token mint to block from deposits"))] - #[codama(account(name = "allowed_mint", docs = "Allowed mint PDA to be closed", writable))] - #[codama(account(name = "token_program", docs = "SPL Token program"))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] + #[codama(account( + name = "allowed_mint", + docs = "Allowed mint PDA to be closed", + writable, + default_value = pda("allowedMint", [seed("escrow", account("escrow")), seed("mint", account("mint"))]) + ))] + #[codama(account(name = "token_program", docs = "SPL Token program", default_value = program("token")))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] BlockMint {} = 7, /// Block a token extension for an escrow. #[codama(account(name = "payer", docs = "Pays for extensions account creation", signer, writable))] #[codama(account(name = "admin", docs = "Admin authority for the escrow", signer))] #[codama(account(name = "escrow", docs = "Escrow account to block extension on"))] - #[codama(account(name = "extensions", docs = "Extensions PDA account to store blocked extensions", writable))] - #[codama(account(name = "system_program", docs = "System program"))] - #[codama(account(name = "event_authority", docs = "Event authority PDA for CPI event emission"))] - #[codama(account(name = "escrow_program", docs = "Escrow program for CPI event emission"))] + #[codama(account( + name = "extensions", + docs = "Extensions PDA account to store blocked extensions", + writable, + default_value = pda("extensions", [seed("escrow", account("escrow"))]) + ))] + #[codama(account(name = "system_program", docs = "System program", default_value = program("system")))] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA for CPI event emission", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + docs = "Escrow program for CPI event emission", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] BlockTokenExtension { /// Bump for extensions PDA + #[codama(default_value = account_bump("extensions"))] extensions_bump: u8, /// Token-2022 ExtensionType value to block blocked_extension: u16, @@ -153,16 +308,33 @@ pub enum EscrowProgramInstruction { #[codama(account(name = "admin", signer))] #[codama(account(name = "arbiter", signer))] #[codama(account(name = "escrow"))] - #[codama(account(name = "extensions", writable))] - #[codama(account(name = "system_program"))] - #[codama(account(name = "event_authority"))] - #[codama(account(name = "escrow_program"))] + #[codama(account( + name = "extensions", + writable, + default_value = pda("extensions", [seed("escrow", account("escrow"))]) + ))] + #[codama(account(name = "system_program", default_value = program("system")))] + #[codama(account( + name = "event_authority", + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] + #[codama(account( + name = "escrow_program", + default_value = public_key("Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg") + ))] SetArbiter { /// Bump for extensions PDA + #[codama(default_value = account_bump("extensions"))] extensions_bump: u8, } = 9, /// Invoked via CPI to emit event data in instruction args (prevents log truncation). - #[codama(account(name = "event_authority", docs = "Event authority PDA that must sign via CPI", signer))] + #[codama(skip)] + #[codama(account( + name = "event_authority", + docs = "Event authority PDA that must sign via CPI", + signer, + default_value = public_key("Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M") + ))] EmitEvent {} = 228, } diff --git a/program/src/state/allowed_mint.rs b/program/src/state/allowed_mint.rs index cff9f1f..e938b31 100644 --- a/program/src/state/allowed_mint.rs +++ b/program/src/state/allowed_mint.rs @@ -17,6 +17,11 @@ use crate::traits::{ /// # PDA Seeds /// `[b"allowed_mint", escrow.as_ref(), mint.as_ref()]` #[derive(Clone, Debug, PartialEq, CodamaAccount)] +#[codama(field("discriminator", number(u8), default_value = 3))] +#[codama(discriminator(field = "discriminator"))] +#[codama(seed(type = string(utf8), value = "allowed_mint"))] +#[codama(seed(name = "escrow", type = public_key))] +#[codama(seed(name = "mint", type = public_key))] #[repr(C)] pub struct AllowedMint { pub bump: u8, diff --git a/program/src/state/escrow.rs b/program/src/state/escrow.rs index f1e16ed..1fe5605 100644 --- a/program/src/state/escrow.rs +++ b/program/src/state/escrow.rs @@ -20,6 +20,10 @@ use crate::traits::{ /// # PDA Seeds /// `[b"escrow", escrow_seed.as_ref()]` #[derive(Clone, Debug, PartialEq, CodamaAccount)] +#[codama(field("discriminator", number(u8), default_value = 0))] +#[codama(discriminator(field = "discriminator"))] +#[codama(seed(type = string(utf8), value = "escrow"))] +#[codama(seed(name = "escrowSeed", type = public_key))] #[repr(C)] pub struct Escrow { pub bump: u8, diff --git a/program/src/state/escrow_extensions.rs b/program/src/state/escrow_extensions.rs index 3741df5..49479f8 100644 --- a/program/src/state/escrow_extensions.rs +++ b/program/src/state/escrow_extensions.rs @@ -46,6 +46,11 @@ pub const TLV_HEADER_SIZE: usize = 4; /// [discriminator: 1][version: 1][header: 2][TLV extensions: variable] /// ``` #[derive(Clone, Debug, PartialEq, CodamaAccount)] +#[codama(field("discriminator", number(u8), default_value = 1))] +#[codama(discriminator(field = "discriminator"))] +#[codama(pda = "extensions")] +#[codama(seed(type = string(utf8), value = "extensions"))] +#[codama(seed(name = "escrow", type = public_key))] #[repr(C)] pub struct EscrowExtensionsHeader { pub bump: u8, diff --git a/program/src/state/receipt.rs b/program/src/state/receipt.rs index 4bbf6cc..945bffd 100644 --- a/program/src/state/receipt.rs +++ b/program/src/state/receipt.rs @@ -15,6 +15,13 @@ use crate::{assert_no_padding, require_account_len, validate_discriminator}; /// # PDA Seeds /// `[b"receipt", escrow.as_ref(), depositor.as_ref(), mint.as_ref(), receipt_seed.as_ref()]` #[derive(Clone, Debug, PartialEq, CodamaAccount)] +#[codama(field("discriminator", number(u8), default_value = 2))] +#[codama(discriminator(field = "discriminator"))] +#[codama(seed(type = string(utf8), value = "receipt"))] +#[codama(seed(name = "escrow", type = public_key))] +#[codama(seed(name = "depositor", type = public_key))] +#[codama(seed(name = "mint", type = public_key))] +#[codama(seed(name = "receiptSeed", type = public_key))] #[repr(C)] pub struct Receipt { pub bump: u8, diff --git a/program/src/utils/associated_token.rs b/program/src/utils/associated_token.rs new file mode 100644 index 0000000..a55f834 --- /dev/null +++ b/program/src/utils/associated_token.rs @@ -0,0 +1,11 @@ +use codama::CodamaPda; + +/// Associated Token Account PDA definition for external program reference. +/// This generates an `additionalPrograms` entry in the IDL with the ATA program's +/// PDA seeds, allowing instruction accounts to reference it via `pda("associatedToken", ...)`. +#[derive(CodamaPda)] +#[codama(program(name = "associatedToken", address = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))] +#[codama(seed(name = "owner", type = public_key))] +#[codama(seed(name = "tokenProgram", type = public_key))] +#[codama(seed(name = "mint", type = public_key))] +pub struct AssociatedToken; diff --git a/program/src/utils/event_utils.rs b/program/src/utils/event_utils.rs index a7a3dab..e7af15c 100644 --- a/program/src/utils/event_utils.rs +++ b/program/src/utils/event_utils.rs @@ -1,3 +1,5 @@ +use codama::CodamaAccount; + use crate::errors::EscrowProgramError::InvalidEventAuthority; use pinocchio::{ account::AccountView, @@ -9,6 +11,11 @@ use pinocchio::{ use crate::events::{event_authority_pda, EVENT_AUTHORITY_SEED}; +/// Event authority PDA — no account data, only used for CPI event emission signing. +#[derive(CodamaAccount)] +#[codama(seed(type = string(utf8), value = "event_authority"))] +pub struct EventAuthority; + /// Verify the account is the event authority PDA, returning an error if it is not. /// /// # Arguments diff --git a/program/src/utils/mod.rs b/program/src/utils/mod.rs index 9caf963..85edd5d 100644 --- a/program/src/utils/mod.rs +++ b/program/src/utils/mod.rs @@ -1,4 +1,5 @@ pub mod account_utils; +pub mod associated_token; pub mod event_utils; pub mod macros; pub mod pda_utils; diff --git a/scripts/generate-clients.ts b/scripts/generate-clients.ts index cf18d60..7ac8bce 100644 --- a/scripts/generate-clients.ts +++ b/scripts/generate-clients.ts @@ -17,14 +17,7 @@ const escrowIdl = JSON.parse(fs.readFileSync(path.join(idlDir, 'escrow_program.j const rustClientsDir = path.join(__dirname, '..', 'clients', 'rust'); const typescriptClientsDir = path.join(__dirname, '..', 'clients', 'typescript'); -const escrowCodama = createEscrowCodamaBuilder(escrowIdl) - .appendAccountDiscriminator() - .appendAccountVersion() - .appendPdaDerivers() - .setInstructionAccountDefaultValues() - .updateInstructionBumps() - .removeEmitInstruction() - .build(); +const escrowCodama = createEscrowCodamaBuilder(escrowIdl).appendAccountVersion().build(); // Preserve configuration files during generation const configPreserver = preserveConfigFiles(typescriptClientsDir, rustClientsDir); diff --git a/scripts/lib/escrow-codama-builder.ts b/scripts/lib/escrow-codama-builder.ts index c0107bf..0c2ab2d 100644 --- a/scripts/lib/escrow-codama-builder.ts +++ b/scripts/lib/escrow-codama-builder.ts @@ -1,12 +1,5 @@ import { Codama, createFromJson } from 'codama'; -import { - appendAccountDiscriminator, - appendAccountVersion, - appendPdaDerivers, - setInstructionAccountDefaultValues, - updateInstructionBumps, -} from './updates/'; -import { removeEmitInstruction } from './updates/remove-emit-instruction'; +import { appendAccountVersion } from './updates/'; /** * Builder for applying Codama IDL transformations before client generation. @@ -19,36 +12,11 @@ export class EscrowCodamaBuilder { this.codama = createFromJson(idlJson); } - appendAccountDiscriminator(): this { - this.codama = appendAccountDiscriminator(this.codama); - return this; - } - appendAccountVersion(): this { this.codama = appendAccountVersion(this.codama); return this; } - appendPdaDerivers(): this { - this.codama = appendPdaDerivers(this.codama); - return this; - } - - setInstructionAccountDefaultValues(): this { - this.codama = setInstructionAccountDefaultValues(this.codama); - return this; - } - - updateInstructionBumps(): this { - this.codama = updateInstructionBumps(this.codama); - return this; - } - - removeEmitInstruction(): this { - this.codama = removeEmitInstruction(this.codama); - return this; - } - build(): Codama { return this.codama; } diff --git a/scripts/lib/updates/append-account-discriminator.ts b/scripts/lib/updates/append-account-discriminator.ts deleted file mode 100644 index cbede09..0000000 --- a/scripts/lib/updates/append-account-discriminator.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Codama, bottomUpTransformerVisitor, structFieldTypeNode, numberTypeNode, assertIsNode, isNode } from 'codama'; - -/** - * Adds discriminator fields to account structs for type-safe deserialization. - */ -export function appendAccountDiscriminator(escrowCodama: Codama): Codama { - escrowCodama.update( - bottomUpTransformerVisitor([ - { - select: '[accountNode]', - transform: node => { - assertIsNode(node, 'accountNode'); - - if (isNode(node.data, 'structTypeNode')) { - const updatedNode = { - ...node, - data: { - ...node.data, - fields: [ - structFieldTypeNode({ - name: 'discriminator', - type: numberTypeNode('u8'), - }), - ...node.data.fields, - ], - }, - }; - - if (node.size !== undefined) { - return { - ...updatedNode, - size: (node.size ?? 0) + 1, - }; - } - - return updatedNode; - } - - return node; - }, - }, - ]), - ); - return escrowCodama; -} diff --git a/scripts/lib/updates/append-pda-derivers.ts b/scripts/lib/updates/append-pda-derivers.ts deleted file mode 100644 index b578fc5..0000000 --- a/scripts/lib/updates/append-pda-derivers.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { - Codama, - constantPdaSeedNode, - stringTypeNode, - stringValueNode, - variablePdaSeedNode, - publicKeyTypeNode, - addPdasVisitor, -} from 'codama'; - -/** - * Adds PDA derivation functions for escrow accounts. - */ -export function appendPdaDerivers(escrowCodama: Codama): Codama { - escrowCodama.update( - addPdasVisitor({ - escrowProgram: [ - { - name: 'escrow', - seeds: [ - constantPdaSeedNode(stringTypeNode('utf8'), stringValueNode('escrow')), - variablePdaSeedNode('escrowSeed', publicKeyTypeNode()), - ], - }, - { - name: 'receipt', - seeds: [ - constantPdaSeedNode(stringTypeNode('utf8'), stringValueNode('receipt')), - variablePdaSeedNode('escrow', publicKeyTypeNode()), - variablePdaSeedNode('depositor', publicKeyTypeNode()), - variablePdaSeedNode('mint', publicKeyTypeNode()), - variablePdaSeedNode('receiptSeed', publicKeyTypeNode()), - ], - }, - { - name: 'allowedMint', - seeds: [ - constantPdaSeedNode(stringTypeNode('utf8'), stringValueNode('allowed_mint')), - variablePdaSeedNode('escrow', publicKeyTypeNode()), - variablePdaSeedNode('mint', publicKeyTypeNode()), - ], - }, - { - name: 'extensions', - seeds: [ - constantPdaSeedNode(stringTypeNode('utf8'), stringValueNode('extensions')), - variablePdaSeedNode('escrow', publicKeyTypeNode()), - ], - }, - { - name: 'eventAuthority', - seeds: [constantPdaSeedNode(stringTypeNode('utf8'), stringValueNode('event_authority'))], - }, - ], - }), - ); - return escrowCodama; -} diff --git a/scripts/lib/updates/index.ts b/scripts/lib/updates/index.ts index 3e3ad12..60c7782 100644 --- a/scripts/lib/updates/index.ts +++ b/scripts/lib/updates/index.ts @@ -1,5 +1 @@ -export { appendAccountDiscriminator } from './append-account-discriminator.js'; export { appendAccountVersion } from './append-account-version.js'; -export { appendPdaDerivers } from './append-pda-derivers.js'; -export { setInstructionAccountDefaultValues } from './set-instruction-account-default-values.js'; -export { updateInstructionBumps } from './update-instruction-bumps.js'; diff --git a/scripts/lib/updates/remove-emit-instruction.ts b/scripts/lib/updates/remove-emit-instruction.ts deleted file mode 100644 index 4a4894e..0000000 --- a/scripts/lib/updates/remove-emit-instruction.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Codama, updateInstructionsVisitor } from 'codama'; - -/** - * Removes the internal emitEvent instruction from client APIs. - */ -export function removeEmitInstruction(escrowCodama: Codama): Codama { - escrowCodama.update( - updateInstructionsVisitor({ - emitEvent: { - delete: true, - }, - }), - ); - return escrowCodama; -} diff --git a/scripts/lib/updates/set-instruction-account-default-values.ts b/scripts/lib/updates/set-instruction-account-default-values.ts deleted file mode 100644 index 26a7ded..0000000 --- a/scripts/lib/updates/set-instruction-account-default-values.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { - Codama, - pdaNode, - pdaValueNode, - pdaSeedValueNode, - publicKeyTypeNode, - accountValueNode, - variablePdaSeedNode, - publicKeyValueNode, - pdaLinkNode, - setInstructionAccountDefaultValuesVisitor, -} from 'codama'; - -const ESCROW_PROGRAM_ID = 'Escrowae7RaUfNn4oEZHywMXE5zWzYCXenwrCDaEoifg'; - -const ATA_PROGRAM_ID = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'; -const SYSTEM_PROGRAM_ID = '11111111111111111111111111111111'; -const EVENT_AUTHORITY_PDA = 'Eq63FWYo9DXgwoTnpK9gjp7BH4PyhSPo11zEF9FK7f4M'; -const TOKEN_PROGRAM_ID = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; - -function createAtaPdaValueNode(ownerAccount: string, mintAccount: string, tokenProgram: string) { - return pdaValueNode( - pdaNode({ - name: 'associatedTokenAccount', - seeds: [ - variablePdaSeedNode('owner', publicKeyTypeNode()), - variablePdaSeedNode('tokenProgram', publicKeyTypeNode()), - variablePdaSeedNode('mint', publicKeyTypeNode()), - ], - programId: ATA_PROGRAM_ID, - }), - [ - pdaSeedValueNode('owner', accountValueNode(ownerAccount)), - pdaSeedValueNode('tokenProgram', accountValueNode(tokenProgram)), - pdaSeedValueNode('mint', accountValueNode(mintAccount)), - ], - ); -} - -/** - * Sets default values for common instruction accounts (program IDs, PDAs, ATAs). - */ -export function setInstructionAccountDefaultValues(escrowCodama: Codama): Codama { - escrowCodama.update( - setInstructionAccountDefaultValuesVisitor([ - // Global Constants - { - account: 'escrowProgram', - defaultValue: publicKeyValueNode(ESCROW_PROGRAM_ID), - }, - { - account: 'tokenProgram', - defaultValue: publicKeyValueNode(TOKEN_PROGRAM_ID), - }, - { - account: 'associatedTokenProgram', - defaultValue: publicKeyValueNode(ATA_PROGRAM_ID), - }, - { - account: 'systemProgram', - defaultValue: publicKeyValueNode(SYSTEM_PROGRAM_ID), - }, - { - account: 'eventAuthority', - defaultValue: publicKeyValueNode(EVENT_AUTHORITY_PDA), - }, - - // PDA Derivations - { - account: 'escrow', - defaultValue: pdaValueNode(pdaLinkNode('escrow'), [ - pdaSeedValueNode('escrowSeed', accountValueNode('escrowSeed')), - ]), - }, - { - account: 'receipt', - defaultValue: pdaValueNode(pdaLinkNode('receipt'), [ - pdaSeedValueNode('escrow', accountValueNode('escrow')), - pdaSeedValueNode('depositor', accountValueNode('depositor')), - pdaSeedValueNode('mint', accountValueNode('mint')), - pdaSeedValueNode('receiptSeed', accountValueNode('receiptSeed')), - ]), - }, - { - account: 'allowedMint', - defaultValue: pdaValueNode(pdaLinkNode('allowedMint'), [ - pdaSeedValueNode('escrow', accountValueNode('escrow')), - pdaSeedValueNode('mint', accountValueNode('mint')), - ]), - }, - { - account: 'extensions', - defaultValue: pdaValueNode(pdaLinkNode('extensions'), [ - pdaSeedValueNode('escrow', accountValueNode('escrow')), - ]), - }, - { - account: 'escrowExtensions', - defaultValue: pdaValueNode(pdaLinkNode('extensions'), [ - pdaSeedValueNode('escrow', accountValueNode('escrow')), - ]), - }, - - // ATAs - { - account: 'vault', - defaultValue: createAtaPdaValueNode('escrow', 'mint', 'tokenProgram'), - }, - { - account: 'depositorTokenAccount', - defaultValue: createAtaPdaValueNode('depositor', 'mint', 'tokenProgram'), - }, - { - account: 'withdrawerTokenAccount', - defaultValue: createAtaPdaValueNode('withdrawer', 'mint', 'tokenProgram'), - }, - ]), - ); - return escrowCodama; -} diff --git a/scripts/lib/updates/update-instruction-bumps.ts b/scripts/lib/updates/update-instruction-bumps.ts deleted file mode 100644 index 883608a..0000000 --- a/scripts/lib/updates/update-instruction-bumps.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Codama, updateInstructionsVisitor, accountBumpValueNode } from 'codama'; - -/** - * Sets default bump values for createEscrow and allowMint instructions. - */ -export function updateInstructionBumps(escrowCodama: Codama): Codama { - escrowCodama.update( - updateInstructionsVisitor({ - createsEscrow: { - arguments: { - bump: { - defaultValue: accountBumpValueNode('escrow'), - }, - }, - }, - allowMint: { - arguments: { - bump: { - defaultValue: accountBumpValueNode('allowedMint'), - }, - }, - }, - addTimelock: { - arguments: { - extensionsBump: { - defaultValue: accountBumpValueNode('extensions'), - }, - }, - }, - setHook: { - arguments: { - extensionsBump: { - defaultValue: accountBumpValueNode('extensions'), - }, - }, - }, - deposit: { - arguments: { - bump: { - defaultValue: accountBumpValueNode('receipt'), - }, - }, - }, - }), - ); - return escrowCodama; -} diff --git a/tests/integration-tests/src/utils/pda_utils.rs b/tests/integration-tests/src/utils/pda_utils.rs index d509f78..4882fbe 100644 --- a/tests/integration-tests/src/utils/pda_utils.rs +++ b/tests/integration-tests/src/utils/pda_utils.rs @@ -1,31 +1,22 @@ -use escrow_program_client::ESCROW_PROGRAM_ID; +use escrow_program_client::accounts::{AllowedMint, Escrow, EscrowExtensionsHeader, EventAuthority, Receipt}; use solana_sdk::pubkey::Pubkey; -const ESCROW_SEED: &[u8] = b"escrow"; -const EXTENSIONS_SEED: &[u8] = b"extensions"; -const EVENT_AUTHORITY_SEED: &[u8] = b"event_authority"; -const RECEIPT_SEED: &[u8] = b"receipt"; -const ALLOWED_MINT_SEED: &[u8] = b"allowed_mint"; - pub fn find_escrow_pda(escrow_seed: &Pubkey) -> (Pubkey, u8) { - Pubkey::find_program_address(&[ESCROW_SEED, escrow_seed.as_ref()], &ESCROW_PROGRAM_ID) + Escrow::find_pda(escrow_seed) } pub fn find_extensions_pda(escrow: &Pubkey) -> (Pubkey, u8) { - Pubkey::find_program_address(&[EXTENSIONS_SEED, escrow.as_ref()], &ESCROW_PROGRAM_ID) + EscrowExtensionsHeader::find_pda(escrow) } pub fn find_event_authority_pda() -> (Pubkey, u8) { - Pubkey::find_program_address(&[EVENT_AUTHORITY_SEED], &ESCROW_PROGRAM_ID) + EventAuthority::find_pda() } pub fn find_receipt_pda(escrow: &Pubkey, depositor: &Pubkey, mint: &Pubkey, receipt_seed: &Pubkey) -> (Pubkey, u8) { - Pubkey::find_program_address( - &[RECEIPT_SEED, escrow.as_ref(), depositor.as_ref(), mint.as_ref(), receipt_seed.as_ref()], - &ESCROW_PROGRAM_ID, - ) + Receipt::find_pda(escrow, depositor, mint, receipt_seed) } pub fn find_allowed_mint_pda(escrow: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) { - Pubkey::find_program_address(&[ALLOWED_MINT_SEED, escrow.as_ref(), mint.as_ref()], &ESCROW_PROGRAM_ID) + AllowedMint::find_pda(escrow, mint) }