Commit Graph

106 Commits

Author SHA1 Message Date
Jon Cinque d3cbe360ac
token-2022: Refactor PrintProgramError impl to error file (#3366) 2022-07-24 21:28:09 +02:00
omertxyz f30ad1d752
Add serde feature - token-2022 (#3291)
* Add serde to token-2022

* Add tests

* Fix feature syntax

* Formatting, enabling features

* Make CI work, and some naming nit cleanup

* Un-async tests

Co-authored-by: jon wong <j@jnwng.com>
Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2022-07-07 13:18:47 -04:00
samkim-crypto 3afe1e652b
Derive elgamal key in token client (#3308)
* token-2022: derive elgamal key in token client

* token-2022: update program tests for key derivation

* token-2022: key derivation for apply pending balance

* token-2022: add configure account with max pending balance

* token-2022: update tests for apply pending balance

* token-2022: derive key for confidential trasfer with fee

* token-2022: update test for confidential transfer with fee

* token-2022: derive encryption keys for withdrawing withheld tokens

* token-2022: update tests
2022-07-04 15:47:33 +09:00
samkim-crypto c3137af9df
token-2022: add tests for withdraw of confidential withheld tokens from accounts (#3280)
* token-2022: add tests for withdraw of confidential withheld tokens from accounts

* token-2022: cargo fmt

* token-2022: cargo clippy
2022-06-21 22:02:15 +09:00
samkim-crypto 677acf173d
token-2022: limit incoming transfers for confidential transfer extension (#3208)
* token-2022: limit incoming transfers for confidential transfer extension

* token-2022: add maximum pending counter for confidential extension in client

* token-2022: update tests for ct configure account

* token-2022: cargo fmt

* divide pending balance into lo and hi

* token-2022: update ct processor for lo and hi pending balances

* token-2022: limit confidential transfer deposit and transfer amount in token client

* token_2022: rename TokenError::IllegalAmount

* token-2022: compare max pending credit as u64

* token-2022: fmt

* token-2022: minor fix error from rebase

* Update token/program-2022/src/extension/confidential_transfer/processor.rs

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

* token-2022: update configure account initialization comments

* token-2022: use strict comparison for max pending balance credit counter check

* token-2022: update deposit tests to check `pending_balance_hi` populated

* token-2022: update deposit tests to check that deposit and transfer fails when max pending exceeded

* token-2022: reset pending balance counter on `ApplyPendingBalance`

* token-2022: fix cargo test cases for credit counter

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2022-06-07 23:16:46 +09:00
samkim-crypto c2a3ecd970
token-2022: prevent an already configured confidential account to be configured again (#3216)
* token-2022: prevent an already configured confidential account to be configured again

* token-2022: add overwrite flag to init extension

* token-2022: clippy

* token-2022: update initialize mint for interest bearing mint

* token-2022: confidential transfer mint init allow overwrite
2022-06-07 09:42:23 +09:00
Jon Cinque f7abf4a6bc
token-2022: Remove `reallocate` and `sibling-instruction` features (#3213) 2022-06-01 16:46:41 +02:00
Jon Cinque 773e2ee469
token-2022: Add interest-bearing extension (#3013)
* token-2022: Add interest-bearing extension

* Rename / comment feedback

* Rename interest-bearing -> interest-bearing mint
2022-06-01 16:46:30 +02:00
samkim-crypto 2ad468f8b7
Fix confidential self transfer with fees (#3193)
* token-2022: fix confidential self-transfers with fee

* token-2022: update tests for confidential self-transfer with fees
2022-05-24 19:19:19 +09:00
Michael Vines f1c693d067
token-2022: Add support for Non-Transferable Tokens (NTTs) - NonTransferableMint extension (#3178)
Co-authored-by: Juan Oxoby <me@jmoxo.by>
2022-05-17 16:16:13 -07:00
Dmitri Makarov 791cc8a776
Use target_os instead of target_arch for Solana conditional compilation (#3148) 2022-05-17 12:25:24 -07:00
samkim-crypto 9e029349fc
Rename encryption pubkey (#3147)
* token-2022: change elgamal pubkey to encryption pubkey

* token-2022: update client and tests for  elgamal pubkey to encryption pubkey
2022-05-08 12:51:18 +09:00
Jon Cinque e59a0dc186
token-2022: Set transfer fee two epochs ahead (#3120) 2022-04-27 17:48:08 +02:00
Tyera Eulberg 51ece68cec
Add feature-wrapping for new ConfidentialTransferInstruction::TransferWithFee (#3116) 2022-04-26 13:15:09 -06:00
Tyera Eulberg 2c1a671a77
Make spl-token-2022 instruction decoders pub (#3112)
* Make instruction decoders pub

* Add missing doc
2022-04-26 07:56:08 -06:00
Tyera Eulberg 2491b29a1e
Add AuthorityType variant to use for mint close-authority adjustment (#3111) 2022-04-26 07:55:15 -06:00
Jon Cinque c616db83c4
token-2022: Add compatibility test for instructions (#3106) 2022-04-22 23:55:18 +02:00
samkim-crypto 049a89f351
token-2022: Add confidential transfer with fee instruction (#2988)
* token-2022: add separate transfer with fee instruction

* token-2022: add `TransferWithFee` client code

* apply twoxtx patch

* token-2022: add brief tests for transfer with fee

* Revert "apply twoxtx patch"

This reverts commit ce09d1f5d2fb496cd4ee9991be234726786e39f2.

* token-2022: cargo fmt

* token-2022: uncommenting the rest of the tests

* token-2022: cargo fmt

* token-2022: temporarily reverting to 5f89521

* token-2022: minor

* token-2022: clippy

* token-2022: apply twoxtx patch

* token-2022: fix transfer with fee test

* Revert "token-2022: apply twoxtx patch"

This reverts commit 577e63c2f38ce0a17fa4aede3d0acfd852b1d3ab.

* token-2022: simplify fee parameter for zkp on client

* token-2022: fix build
2022-04-22 14:00:42 -04:00
Jon Cinque 2292dc2c8c
token-2022: Refactor instruction encoding / decoding (#3011) 2022-03-17 18:27:06 +01:00
samkim-crypto 4ddaae5f21
Bump zk token sdk (#3002)
* token-2022: bumping zk-token-sdk to 1.10.1-pre1 and updating variable names accordingly

* token-2022: updating client and test variables to match newest zk-token-sdk
2022-03-11 06:57:32 -05:00
Jon Cinque 29479fcc72
token-2022: Make program and crate deployable (#2985)
* token-2022: Make program and crate deployable

* Featurize the syscall usage

* Re-add GenericTokenAccount

* Rebase correctly with GenericTokenAccount

* Add updated valid_account_data implementation
2022-03-10 17:42:16 +01:00
Tyera Eulberg 810c79ec32
token-2022: Allow anyone to burn/close an Account owned by the system program or the incinerator (#2890)
* Allow anyone to burn and close token Accounts owned by the system program and the incinerator

* Require rent from incinerator/system-owned token accounts be burnt when accounts closed

* Add support to OG program
2022-03-09 19:31:39 -07:00
Lijun Wang 76a92cda2d
Added checks if a token account is initialized when checking validity (#2986)
* Added checks if an account is initialized when checking validity
2022-03-09 16:53:48 -08:00
samkim-crypto 7ab4de6174
token-2022: minor rename pod types with descriptive types (#2983) 2022-03-04 12:26:28 -05:00
Tyera Eulberg e17706c7be
Spell out destination (#2977) 2022-03-03 12:34:17 -07:00
Lijun Wang bbbf250a67
Support unpacking token accounts fields partially (#2970)
* Support unpacking token accounts fields partially

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2022-03-02 11:34:55 -08:00
Michael Vines 22135e547c Add ConfidentialTransferInstruction Deposit/Transfer/Withdraw tests 2022-02-28 09:34:23 -08:00
Michael Vines 3450f173de Fix transfer bug 2022-02-28 09:34:23 -08:00
Tyera Eulberg 29089e873e
Fix copypasta (#2962) 2022-02-26 13:28:57 -07:00
samkim-crypto 66cf3e9720
token-2022: update doc style for confidential extension instructions (#2961) 2022-02-26 09:21:48 -05:00
samkim-crypto af90facd1d
token-2022: add fee withdraw and harvest instructions (#2907)
* token-2022: add fee harvest instruction for confidential extension

* token-2022: cargo fmt

* token-2022: add `WithdrawWithheldTokensMint` processor

* token-2022: add `WithdrawWithheldTokensAccounts` processor

* token-2022: incorporate VerifyWithdrawWithheldTokens instruction

* token-2022: minor variable name changes

* token-2022: additional comments + renaming variables

* token-2022: check if confidential extension was approved for fee harvest

Co-authored-by: Michael Vines <mvines@gmail.com>

* token-2022: fix error type for overflow

* token-2022: remove unnecessary fee extension check for confidential token harvest

* token-2022: add extra detail on front-running for harvesting fees

* token-2022: fix pending balance

* token-2022: bump zk-token-sdk to 0.8.0

* token-2022: fix minor variable name issue

* token-2022: minor spelling

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>

* token-2022: addressing smaller review feedback

* token-2022: change fee_mint to transfer_fee_config in confidential transfer

* Update token/program-2022/Cargo.toml

* token-2022: fix cargo bpf-test fail

* token-2022: fixing a previous comment mistake

Co-authored-by: Michael Vines <mvines@gmail.com>
Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
2022-02-24 21:16:32 -05:00
Tyera Eulberg 0268d76d30
token-2022: complete memo extension functionality (#2876)
* Add NoMemo error and use syscall to require memos

* Flesh out + dedupe memo-transfer tests

* Add memo v1 test cases
2022-02-24 16:48:42 -07:00
Michael Vines 131612417a Do not permit token accounts to be closed when the withheld amount is non-zero 2022-02-23 11:48:03 -08:00
Michael Vines 10559aed7a Reduce mut usage 2022-02-23 11:48:03 -08:00
Michael Vines 1bcd07dca1 Field name cleanup 2022-02-23 09:54:46 -08:00
Michael Vines e111e997b7 Add {En,Dis}ableBalanceCredits test 2022-02-23 08:37:19 -08:00
Michael Vines 7bdb77b330 Enable balance credits by default 2022-02-23 08:37:19 -08:00
Michael Vines 3f393e8a85 Remove unnecessary approval checks 2022-02-23 08:37:19 -08:00
Michael Vines 7c3b614af0 Add confidential transfer configure and approve account tests 2022-02-23 07:37:14 -08:00
Michael Vines c4c14b5c51 Add confidential transfer initialize/update mint tests 2022-02-22 21:25:18 -07:00
Tyera Eulberg 3d92f8f4dc
Add token Amount/UiAmount conversion Instructions (#2928)
* Add Amount/UiAmount conversion Instructions to spl-token

* Use invalid-mint error in spl_token get_account_data_size

* Add Amount/UiAmount conversion Instructions to spl-token-2022
2022-02-17 16:25:57 -07:00
Jon Cinque 558322798f
token-2022: Support extensions in `SyncNative` (#2926) 2022-02-17 22:50:10 +01:00
Tyera Eulberg 172e24e1f2
Initialize close_authority explicitly (#2919) 2022-02-15 17:27:28 -07:00
Jon Cinque 20864c0be7
token: Support both token programs in associated-token-account (#2904)
* token: Support both token programs in associated-token-account

* Rename spl-token -> spl-token-2022, spl-token-legacy -> spl-token

* Use spl-token by default

* Check mint in get_account_data_len

* Add checks for either token program

* Rebase fix

* Update version comments in tests
2022-02-15 14:20:14 +01:00
samkim-crypto 7330b17482
token-2022: add fee for confidential extension (#2897)
* token-2022: add fee for confidential extension

* token-2022: change receiver to dest for consistency

* token-2022: addressing readability review comments for confidential extension
2022-02-11 08:37:30 -05:00
Michael Vines 2e968115ab Add CreateNativeMint instruction 2022-02-09 20:03:21 -08:00
Michael Vines f36e973697 Update program id 2022-02-08 11:59:50 -08:00
Tyera Eulberg c3ad86dc2c
token-2022: fixup set_account_type to confirm AccountType (#2885)
* Add failing test

* Prevent cross-type set_account_types
2022-02-08 10:06:23 -07:00
Tyera Eulberg 482a9281f6
token-2022: Add MemoTransfer extension (#2822)
* Style nits

* Initial MemoTransfer extension

* Stub in check for memo

* Add memo-transfer token-client method

* Add MemoTransfer tests

* Add immutable get_extension, and clean up mod

* Update token/program-2022/src/extension/memo_transfer/instruction.rs

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* Update token/rust/src/token.rs

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2022-02-04 17:12:01 -07:00
Tyera Eulberg c7ec4427b6
token-2022: Add Reallocate instruction (#2864)
* Pass by ref

* Dedupe ExtensionTypes in length apis

* Depend on deduplication in ExtensionType::get_account_len

* Add Reallocate instruction

* Remove unneeded api

* Add set_account_type helper and remove unneeded StateWithExtensionsMut api
2022-02-04 15:23:16 -07:00