Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token 2022 Support #85

Merged
merged 42 commits into from
Jan 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
cd2072c
feat: add token-2022 program
bigearsenal Jan 4, 2024
3295604
fix: folder structure
bigearsenal Jan 4, 2024
169dd60
feat: Token2022 BufferLayout
bigearsenal Jan 4, 2024
832c0ad
Merge branch 'main' into feature/token-2022
bigearsenal Jan 4, 2024
987a380
feat: Token2022ProgramTests
bigearsenal Jan 4, 2024
7208343
feat: separate tests
bigearsenal Jan 4, 2024
de8506d
feat: getTokenAccounts
bigearsenal Jan 5, 2024
f006281
feat: add tests
bigearsenal Jan 5, 2024
0ac32b0
fix: programId
bigearsenal Jan 5, 2024
e3ee72a
feat: mintdata
bigearsenal Jan 5, 2024
0e4bc8e
fix: optional type
bigearsenal Jan 5, 2024
2e52217
fix: tokenMetadata
bigearsenal Jan 5, 2024
042ed3b
feat: add minRentExempt
bigearsenal Jan 9, 2024
8babbb7
feat: some fixes
bigearsenal Jan 9, 2024
80c8a71
feat: define program to send
bigearsenal Jan 9, 2024
04d339d
feat: add lamportsPerSignature
bigearsenal Jan 11, 2024
a1d3cec
feat: remove generic
bigearsenal Jan 11, 2024
af02f17
feat: reverse
bigearsenal Jan 11, 2024
f1b8802
Merge branch 'feature/remove-generic' into feature/token-2022
bigearsenal Jan 11, 2024
0cc2f5d
fix: update CHANGELOG.md
bigearsenal Jan 11, 2024
454c363
feat: mock data
bigearsenal Jan 11, 2024
afab465
feat: add test for getAccountBalances
bigearsenal Jan 12, 2024
99d2cde
Merge branch 'feature/get-account-balances-tests' into feature/token-…
bigearsenal Jan 12, 2024
2cbdb61
fix: getAccountBalances
bigearsenal Jan 12, 2024
44fe66b
Merge branch 'main' into feature/token-2022
TrGiLong Jan 15, 2024
0edf5bc
feat: prepare for parsing extension
bigearsenal Jan 22, 2024
c2c81bd
feat: parse extensions
bigearsenal Jan 23, 2024
40bc44e
feat: add test cases
bigearsenal Jan 23, 2024
ad3580b
feat: some fixes
bigearsenal Jan 23, 2024
5f465c5
feat: InterestBearingConfig
bigearsenal Jan 23, 2024
acdbf73
feat: convenience method for getting extension
bigearsenal Jan 23, 2024
68509d8
feat: getParsedExtension
bigearsenal Jan 23, 2024
e072989
Merge branch 'feature/token-2022-extension' into feature/token-2022
bigearsenal Jan 23, 2024
e398f69
Update README.md
bigearsenal Jan 24, 2024
11f824f
Update README.md
bigearsenal Jan 24, 2024
5827e9f
fix: encoding tests
bigearsenal Jan 24, 2024
4100ad8
feat: VecU8
bigearsenal Jan 24, 2024
e66f37d
feat: VecU8
bigearsenal Jan 24, 2024
352b154
fix: encoding
bigearsenal Jan 24, 2024
40bf0b0
feat: MintLayoutState
bigearsenal Jan 24, 2024
c67f9a7
feat: rename TokenAccountState & TokenMintState
bigearsenal Jan 24, 2024
5c3b9b9
Merge pull request #89 from p2p-org/feature/token-2022-renaming
bigearsenal Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: prepare for parsing extension
bigearsenal committed Jan 22, 2024
commit 0edf5bc68e908b81b5afe11f0d5b0348caacf6ff
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import Foundation

enum ExtensionType: UInt16 {
/// Used as padding if the account size would otherwise be 355, same as a
/// multisig
case Uninitialized
/// Includes transfer fee rate info and accompanying authorities to withdraw
/// and set the fee
case TransferFeeConfig
/// Includes withheld transfer fees
case TransferFeeAmount
/// Includes an optional mint close authority
case MintCloseAuthority
/// Auditor configuration for confidential transfers
case ConfidentialTransferMint
/// State for confidential transfers
case ConfidentialTransferAccount
/// Specifies the default Account::state for new Accounts
case DefaultAccountState
/// Indicates that the Account owner authority cannot be changed
case ImmutableOwner
/// Require inbound transfers to have memo
case MemoTransfer
/// Indicates that the tokens from this mint can't be transfered
case NonTransferable
/// Tokens accrue interest over time,
case InterestBearingConfig
/// Locks privileged token operations from happening via CPI
case CpiGuard
/// Includes an optional permanent delegate
case PermanentDelegate
/// Indicates that the tokens in this account belong to a non-transferable
/// mint
case NonTransferableAccount
/// Mint requires a CPI to a program implementing the "transfer hook"
/// interface
case TransferHook
/// Indicates that the tokens in this account belong to a mint with a
/// transfer hook
case TransferHookAccount
/// Includes encrypted withheld fees and the encryption public that they are
/// encrypted under
case ConfidentialTransferFeeConfig
/// Includes confidential withheld transfer fees
case ConfidentialTransferFeeAmount
/// Mint contains a pointer to another account (or the same account) that
/// holds metadata
case MetadataPointer
/// Mint contains token-metadata
case TokenMetadata
/// Mint contains a pointer to another account (or the same account) that
/// holds group configurations
case GroupPointer
/// Mint contains token group configurations
case TokenGroup
/// Mint contains a pointer to another account (or the same account) that
/// holds group member configurations
case GroupMemberPointer
/// Mint contains token group member configurations
case TokenGroupMember

// MARK: - Test only

// /// Test variable-length mint extension
// case VariableLenMintTest = UInt16.max - 2,
// /// Padding extension used to make an account exactly Multisig::LEN, used
// /// for testing
// case AccountPaddingTest = UInt16.max - 1
// /// Padding extension used to make a mint exactly Multisig::LEN, used for
// /// testing
// case MintPaddingTest = UInt16.max
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation

struct Token2022Extension: BorshCodable {
let type: ExtensionType
let data: Data

func serialize(to _: inout Data) throws {}

init(from reader: inout BinaryReader) throws {
let type = try ExtensionType(rawValue: UInt16(from: &reader))
guard let type else {
throw BorshCodableError.invalidData
}
self.type = type
let length = try UInt16(from: &reader)
data = try Data(reader.read(count: Int(length)))
}
}
Original file line number Diff line number Diff line change
@@ -75,5 +75,7 @@ extension Token2022AccountState: BorshCodable {
delegatedAmount = oldTokenProgramData.delegatedAmount
closeAuthorityOption = oldTokenProgramData.closeAuthorityOption
closeAuthority = oldTokenProgramData.closeAuthority

_ = try reader.read(count: 1) // account type
}
}
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ extension Token2022MintState: BorshCodable {
isInitialized = oldTokenMintState.isInitialized
freezeAuthorityOption = oldTokenMintState.freezeAuthorityOption
freezeAuthority = oldTokenMintState.freezeAuthority

_ = try reader.read(count: 83) // padding
_ = try reader.read(count: 1) // account type
}

public func serialize(to writer: inout Data) throws {