Skip to content

Commit

Permalink
Merge pull request #17 from dephy-io/dephy-id-wallet
Browse files Browse the repository at this point in the history
Dephy id wallet
  • Loading branch information
jasl authored Jun 30, 2024
2 parents 2b991b0 + 40794e6 commit 3b29527
Show file tree
Hide file tree
Showing 105 changed files with 10,399 additions and 591 deletions.
542 changes: 358 additions & 184 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ thiserror = "1.0.61"
serde = "1.0.202"
serde_with = "3.8.1"
assert_matches = "1.5.0"
solana-program = "2.0.0"
solana-program-test = "2.0.0"
solana-sdk = "2.0.0"
solana-client = "2.0.0"
solana-zk-token-sdk = "2.0.0"
spl-associated-token-account = "3.0.2"
spl-token-2022 = "3.0.2"
spl-token-metadata-interface = "0.3.3"
solana-program = "2.0.1"
solana-program-test = "2.0.1"
solana-sdk = "2.0.1"
solana-client = "2.0.1"
solana-zk-token-sdk = "2.0.1"
spl-associated-token-account = "4.0.0"
spl-token-2022 = "4.0.0"
spl-token-metadata-interface = "0.4.0"
ed25519-dalek = "1.0.1"
libsecp256k1 = "0.7.1"
clap = "4.5.4"
Expand Down
75 changes: 69 additions & 6 deletions clients/js/dist/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clients/js/dist/src/index.js.map

Large diffs are not rendered by default.

76 changes: 68 additions & 8 deletions clients/js/dist/src/index.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { getProgramDerivedAddress, getUtf8Encoder, getAddressEncoder, getDiscriminatedUnionEncoder, getStructEncoder, getTupleEncoder, fixEncoderSize, getBytesEncoder, getU8Encoder, getDiscriminatedUnionDecoder, getStructDecoder, getTupleDecoder, fixDecoderSize, getBytesDecoder, getU8Decoder, combineCodec, getEnumEncoder, getEnumDecoder, transformEncoder, getAddressDecoder, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, getU64Encoder, getU64Decoder, addEncoderSizePrefix, getU32Encoder, getArrayEncoder, addDecoderSizePrefix, getUtf8Decoder, getU32Decoder, getArrayDecoder, AccountRole, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/web3.js';
import { getProgramDerivedAddress, getAddressEncoder, address, getUtf8Encoder, getDiscriminatedUnionEncoder, getStructEncoder, getTupleEncoder, fixEncoderSize, getBytesEncoder, getU8Encoder, getDiscriminatedUnionDecoder, getStructDecoder, getTupleDecoder, fixDecoderSize, getBytesDecoder, getU8Decoder, combineCodec, getEnumEncoder, getEnumDecoder, transformEncoder, getAddressDecoder, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, getU64Encoder, getU64Decoder, addEncoderSizePrefix, getU32Encoder, getArrayEncoder, addDecoderSizePrefix, getUtf8Decoder, getU32Decoder, getArrayDecoder, AccountRole, upgradeRoleToSigner, isTransactionSigner as isTransactionSigner$1 } from '@solana/web3.js';

// env-shim.ts
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
async function findDeviceATokenPda(seeds, config = {}) {
const {
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
} = config;
return await getProgramDerivedAddress({
programAddress,
seeds: [
getAddressEncoder().encode(seeds.ownerPubkey),
getAddressEncoder().encode(
address("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb")
),
getAddressEncoder().encode(seeds.deviceMintPubkey)
]
});
}
async function findDeviceMintPda(seeds, config = {}) {
const {
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
Expand All @@ -15,6 +30,21 @@ async function findDeviceMintPda(seeds, config = {}) {
]
});
}
async function findProductATokenPda(seeds, config = {}) {
const {
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
} = config;
return await getProgramDerivedAddress({
programAddress,
seeds: [
getAddressEncoder().encode(seeds.devicePubkey),
getAddressEncoder().encode(
address("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb")
),
getAddressEncoder().encode(seeds.productMintPubkey)
]
});
}
async function findProductMintPda(seeds, config = {}) {
const {
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
Expand All @@ -28,6 +58,15 @@ async function findProductMintPda(seeds, config = {}) {
]
});
}
async function findProgramDataPda(config = {}) {
const {
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
} = config;
return await getProgramDerivedAddress({
programAddress,
seeds: [getUtf8Encoder().encode("DePHY_ID")]
});
}
async function findProgramDataAccountPda(config = {}) {
const {
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
Expand Down Expand Up @@ -188,13 +227,13 @@ function decodeProgramDataAccount(encodedAccount) {
getProgramDataAccountDecoder()
);
}
async function fetchProgramDataAccount(rpc, address, config) {
const maybeAccount = await fetchMaybeProgramDataAccount(rpc, address, config);
async function fetchProgramDataAccount(rpc, address3, config) {
const maybeAccount = await fetchMaybeProgramDataAccount(rpc, address3, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}
async function fetchMaybeProgramDataAccount(rpc, address, config) {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
async function fetchMaybeProgramDataAccount(rpc, address3, config) {
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
return decodeProgramDataAccount(maybeAccount);
}
async function fetchAllProgramDataAccount(rpc, addresses, config) {
Expand Down Expand Up @@ -222,8 +261,8 @@ async function fetchProgramDataAccountFromSeeds(rpc, config = {}) {
}
async function fetchMaybeProgramDataAccountFromSeeds(rpc, config = {}) {
const { programAddress, ...fetchConfig } = config;
const [address] = await findProgramDataAccountPda({ programAddress });
return await fetchMaybeProgramDataAccount(rpc, address, fetchConfig);
const [address3] = await findProgramDataAccountPda({ programAddress });
return await fetchMaybeProgramDataAccount(rpc, address3, fetchConfig);
}

// src/generated/errors/dephyId.ts
Expand Down Expand Up @@ -307,6 +346,12 @@ function identifyDephyIdInstruction(instruction) {
"The provided instruction could not be identified as a dephyId instruction."
);
}
function expectSome(value) {
if (value == null) {
throw new Error("Expected a value but received null or undefined.");
}
return value;
}
function expectAddress(value) {
if (!value) {
throw new Error("Expected a Address.");
Expand Down Expand Up @@ -392,6 +437,9 @@ function getActivateDeviceInstruction(input) {
if (!accounts.systemProgram.value) {
accounts.systemProgram.value = "11111111111111111111111111111111";
}
if (!accounts.token2022Program.value) {
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
}
if (!accounts.ataProgram.value) {
accounts.ataProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
}
Expand Down Expand Up @@ -515,9 +563,15 @@ function getCreateActivatedDeviceInstruction(input) {
if (!accounts.systemProgram.value) {
accounts.systemProgram.value = "11111111111111111111111111111111";
}
if (!accounts.token2022Program.value) {
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
}
if (!accounts.ataProgram.value) {
accounts.ataProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
}
if (!accounts.payer.value) {
accounts.payer.value = expectSome(accounts.vendor.value);
}
const getAccountMeta = getAccountMetaFactory(programAddress);
const instruction = {
accounts: [
Expand Down Expand Up @@ -643,6 +697,9 @@ function getCreateDeviceInstruction(input) {
if (!accounts.ataProgram.value) {
accounts.ataProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
}
if (!accounts.payer.value) {
accounts.payer.value = expectSome(accounts.vendor.value);
}
const getAccountMeta = getAccountMetaFactory(programAddress);
const instruction = {
accounts: [
Expand Down Expand Up @@ -824,6 +881,9 @@ function getInitializeInstruction(input) {
if (!accounts.systemProgram.value) {
accounts.systemProgram.value = "11111111111111111111111111111111";
}
if (!accounts.payer.value) {
accounts.payer.value = expectSome(accounts.authority.value);
}
const getAccountMeta = getAccountMetaFactory(programAddress);
const instruction = {
accounts: [
Expand Down Expand Up @@ -861,6 +921,6 @@ function parseInitializeInstruction(instruction) {
};
}

export { DEPHY_ID_ERROR__ACCOUNT_MISMATCH, DEPHY_ID_ERROR__DESERIALIZATION_ERROR, DEPHY_ID_ERROR__EXPECTED_EMPTY_ACCOUNT, DEPHY_ID_ERROR__EXPECTED_NON_EMPTY_ACCOUNT, DEPHY_ID_ERROR__EXPECTED_SIGNER_ACCOUNT, DEPHY_ID_ERROR__EXPECTED_WRITABLE_ACCOUNT, DEPHY_ID_ERROR__INVALID_ACCOUNT_KEY, DEPHY_ID_ERROR__INVALID_PDA, DEPHY_ID_ERROR__INVALID_PROGRAM_OWNER, DEPHY_ID_ERROR__MISSING_INSTRUCTION, DEPHY_ID_ERROR__NUMERICAL_OVERFLOW, DEPHY_ID_ERROR__SERIALIZATION_ERROR, DEPHY_ID_ERROR__SIGNATURE_MISMATCH, DEPHY_ID_PROGRAM_ADDRESS, DephyIdAccount, DephyIdInstruction, DeviceSigningAlgorithm, Key, decodeProgramDataAccount, deviceActivationSignature, fetchAllMaybeProgramDataAccount, fetchAllProgramDataAccount, fetchMaybeProgramDataAccount, fetchMaybeProgramDataAccountFromSeeds, fetchProgramDataAccount, fetchProgramDataAccountFromSeeds, findDeviceMintPda, findProductMintPda, findProgramDataAccountPda, getActivateDeviceInstruction, getActivateDeviceInstructionDataCodec, getActivateDeviceInstructionDataDecoder, getActivateDeviceInstructionDataEncoder, getCreateActivatedDeviceInstruction, getCreateActivatedDeviceInstructionDataCodec, getCreateActivatedDeviceInstructionDataDecoder, getCreateActivatedDeviceInstructionDataEncoder, getCreateDeviceInstruction, getCreateDeviceInstructionDataCodec, getCreateDeviceInstructionDataDecoder, getCreateDeviceInstructionDataEncoder, getCreateProductInstruction, getCreateProductInstructionDataCodec, getCreateProductInstructionDataDecoder, getCreateProductInstructionDataEncoder, getDephyIdErrorMessage, getDeviceActivationSignatureCodec, getDeviceActivationSignatureDecoder, getDeviceActivationSignatureEncoder, getDeviceSigningAlgorithmCodec, getDeviceSigningAlgorithmDecoder, getDeviceSigningAlgorithmEncoder, getInitializeInstruction, getInitializeInstructionDataCodec, getInitializeInstructionDataDecoder, getInitializeInstructionDataEncoder, getKeyCodec, getKeyDecoder, getKeyEncoder, getProgramDataAccountCodec, getProgramDataAccountDecoder, getProgramDataAccountEncoder, getProgramDataAccountSize, getProgramDataCodec, getProgramDataDecoder, getProgramDataEncoder, identifyDephyIdAccount, identifyDephyIdInstruction, isDeviceActivationSignature, parseActivateDeviceInstruction, parseCreateActivatedDeviceInstruction, parseCreateDeviceInstruction, parseCreateProductInstruction, parseInitializeInstruction };
export { DEPHY_ID_ERROR__ACCOUNT_MISMATCH, DEPHY_ID_ERROR__DESERIALIZATION_ERROR, DEPHY_ID_ERROR__EXPECTED_EMPTY_ACCOUNT, DEPHY_ID_ERROR__EXPECTED_NON_EMPTY_ACCOUNT, DEPHY_ID_ERROR__EXPECTED_SIGNER_ACCOUNT, DEPHY_ID_ERROR__EXPECTED_WRITABLE_ACCOUNT, DEPHY_ID_ERROR__INVALID_ACCOUNT_KEY, DEPHY_ID_ERROR__INVALID_PDA, DEPHY_ID_ERROR__INVALID_PROGRAM_OWNER, DEPHY_ID_ERROR__MISSING_INSTRUCTION, DEPHY_ID_ERROR__NUMERICAL_OVERFLOW, DEPHY_ID_ERROR__SERIALIZATION_ERROR, DEPHY_ID_ERROR__SIGNATURE_MISMATCH, DEPHY_ID_PROGRAM_ADDRESS, DephyIdAccount, DephyIdInstruction, DeviceSigningAlgorithm, Key, decodeProgramDataAccount, deviceActivationSignature, fetchAllMaybeProgramDataAccount, fetchAllProgramDataAccount, fetchMaybeProgramDataAccount, fetchMaybeProgramDataAccountFromSeeds, fetchProgramDataAccount, fetchProgramDataAccountFromSeeds, findDeviceATokenPda, findDeviceMintPda, findProductATokenPda, findProductMintPda, findProgramDataAccountPda, findProgramDataPda, getActivateDeviceInstruction, getActivateDeviceInstructionDataCodec, getActivateDeviceInstructionDataDecoder, getActivateDeviceInstructionDataEncoder, getCreateActivatedDeviceInstruction, getCreateActivatedDeviceInstructionDataCodec, getCreateActivatedDeviceInstructionDataDecoder, getCreateActivatedDeviceInstructionDataEncoder, getCreateDeviceInstruction, getCreateDeviceInstructionDataCodec, getCreateDeviceInstructionDataDecoder, getCreateDeviceInstructionDataEncoder, getCreateProductInstruction, getCreateProductInstructionDataCodec, getCreateProductInstructionDataDecoder, getCreateProductInstructionDataEncoder, getDephyIdErrorMessage, getDeviceActivationSignatureCodec, getDeviceActivationSignatureDecoder, getDeviceActivationSignatureEncoder, getDeviceSigningAlgorithmCodec, getDeviceSigningAlgorithmDecoder, getDeviceSigningAlgorithmEncoder, getInitializeInstruction, getInitializeInstructionDataCodec, getInitializeInstructionDataDecoder, getInitializeInstructionDataEncoder, getKeyCodec, getKeyDecoder, getKeyEncoder, getProgramDataAccountCodec, getProgramDataAccountDecoder, getProgramDataAccountEncoder, getProgramDataAccountSize, getProgramDataCodec, getProgramDataDecoder, getProgramDataEncoder, identifyDephyIdAccount, identifyDephyIdInstruction, isDeviceActivationSignature, parseActivateDeviceInstruction, parseCreateActivatedDeviceInstruction, parseCreateDeviceInstruction, parseCreateProductInstruction, parseInitializeInstruction };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.mjs.map
2 changes: 1 addition & 1 deletion clients/js/dist/src/index.mjs.map

Large diffs are not rendered by default.

Loading

0 comments on commit 3b29527

Please sign in to comment.