Skip to content

Commit 3b29527

Browse files
authored
Merge pull request #17 from dephy-io/dephy-id-wallet
Dephy id wallet
2 parents 2b991b0 + 40794e6 commit 3b29527

File tree

105 files changed

+10399
-591
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+10399
-591
lines changed

Cargo.lock

Lines changed: 358 additions & 184 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ thiserror = "1.0.61"
2222
serde = "1.0.202"
2323
serde_with = "3.8.1"
2424
assert_matches = "1.5.0"
25-
solana-program = "2.0.0"
26-
solana-program-test = "2.0.0"
27-
solana-sdk = "2.0.0"
28-
solana-client = "2.0.0"
29-
solana-zk-token-sdk = "2.0.0"
30-
spl-associated-token-account = "3.0.2"
31-
spl-token-2022 = "3.0.2"
32-
spl-token-metadata-interface = "0.3.3"
25+
solana-program = "2.0.1"
26+
solana-program-test = "2.0.1"
27+
solana-sdk = "2.0.1"
28+
solana-client = "2.0.1"
29+
solana-zk-token-sdk = "2.0.1"
30+
spl-associated-token-account = "4.0.0"
31+
spl-token-2022 = "4.0.0"
32+
spl-token-metadata-interface = "0.4.0"
3333
ed25519-dalek = "1.0.1"
3434
libsecp256k1 = "0.7.1"
3535
clap = "4.5.4"

clients/js/dist/src/index.js

Lines changed: 69 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/js/dist/src/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/js/dist/src/index.mjs

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
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';
1+
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';
22

33
// env-shim.ts
44
var __DEV__ = /* @__PURE__ */ (() => process["env"].NODE_ENV === "development")();
5+
async function findDeviceATokenPda(seeds, config = {}) {
6+
const {
7+
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
8+
} = config;
9+
return await getProgramDerivedAddress({
10+
programAddress,
11+
seeds: [
12+
getAddressEncoder().encode(seeds.ownerPubkey),
13+
getAddressEncoder().encode(
14+
address("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb")
15+
),
16+
getAddressEncoder().encode(seeds.deviceMintPubkey)
17+
]
18+
});
19+
}
520
async function findDeviceMintPda(seeds, config = {}) {
621
const {
722
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
@@ -15,6 +30,21 @@ async function findDeviceMintPda(seeds, config = {}) {
1530
]
1631
});
1732
}
33+
async function findProductATokenPda(seeds, config = {}) {
34+
const {
35+
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
36+
} = config;
37+
return await getProgramDerivedAddress({
38+
programAddress,
39+
seeds: [
40+
getAddressEncoder().encode(seeds.devicePubkey),
41+
getAddressEncoder().encode(
42+
address("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb")
43+
),
44+
getAddressEncoder().encode(seeds.productMintPubkey)
45+
]
46+
});
47+
}
1848
async function findProductMintPda(seeds, config = {}) {
1949
const {
2050
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
@@ -28,6 +58,15 @@ async function findProductMintPda(seeds, config = {}) {
2858
]
2959
});
3060
}
61+
async function findProgramDataPda(config = {}) {
62+
const {
63+
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
64+
} = config;
65+
return await getProgramDerivedAddress({
66+
programAddress,
67+
seeds: [getUtf8Encoder().encode("DePHY_ID")]
68+
});
69+
}
3170
async function findProgramDataAccountPda(config = {}) {
3271
const {
3372
programAddress = "hdMghjD73uASxgJXi6e1mGPsXqnADMsrqB1bveqABP1"
@@ -188,13 +227,13 @@ function decodeProgramDataAccount(encodedAccount) {
188227
getProgramDataAccountDecoder()
189228
);
190229
}
191-
async function fetchProgramDataAccount(rpc, address, config) {
192-
const maybeAccount = await fetchMaybeProgramDataAccount(rpc, address, config);
230+
async function fetchProgramDataAccount(rpc, address3, config) {
231+
const maybeAccount = await fetchMaybeProgramDataAccount(rpc, address3, config);
193232
assertAccountExists(maybeAccount);
194233
return maybeAccount;
195234
}
196-
async function fetchMaybeProgramDataAccount(rpc, address, config) {
197-
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
235+
async function fetchMaybeProgramDataAccount(rpc, address3, config) {
236+
const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
198237
return decodeProgramDataAccount(maybeAccount);
199238
}
200239
async function fetchAllProgramDataAccount(rpc, addresses, config) {
@@ -222,8 +261,8 @@ async function fetchProgramDataAccountFromSeeds(rpc, config = {}) {
222261
}
223262
async function fetchMaybeProgramDataAccountFromSeeds(rpc, config = {}) {
224263
const { programAddress, ...fetchConfig } = config;
225-
const [address] = await findProgramDataAccountPda({ programAddress });
226-
return await fetchMaybeProgramDataAccount(rpc, address, fetchConfig);
264+
const [address3] = await findProgramDataAccountPda({ programAddress });
265+
return await fetchMaybeProgramDataAccount(rpc, address3, fetchConfig);
227266
}
228267

229268
// src/generated/errors/dephyId.ts
@@ -307,6 +346,12 @@ function identifyDephyIdInstruction(instruction) {
307346
"The provided instruction could not be identified as a dephyId instruction."
308347
);
309348
}
349+
function expectSome(value) {
350+
if (value == null) {
351+
throw new Error("Expected a value but received null or undefined.");
352+
}
353+
return value;
354+
}
310355
function expectAddress(value) {
311356
if (!value) {
312357
throw new Error("Expected a Address.");
@@ -392,6 +437,9 @@ function getActivateDeviceInstruction(input) {
392437
if (!accounts.systemProgram.value) {
393438
accounts.systemProgram.value = "11111111111111111111111111111111";
394439
}
440+
if (!accounts.token2022Program.value) {
441+
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
442+
}
395443
if (!accounts.ataProgram.value) {
396444
accounts.ataProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
397445
}
@@ -515,9 +563,15 @@ function getCreateActivatedDeviceInstruction(input) {
515563
if (!accounts.systemProgram.value) {
516564
accounts.systemProgram.value = "11111111111111111111111111111111";
517565
}
566+
if (!accounts.token2022Program.value) {
567+
accounts.token2022Program.value = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
568+
}
518569
if (!accounts.ataProgram.value) {
519570
accounts.ataProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
520571
}
572+
if (!accounts.payer.value) {
573+
accounts.payer.value = expectSome(accounts.vendor.value);
574+
}
521575
const getAccountMeta = getAccountMetaFactory(programAddress);
522576
const instruction = {
523577
accounts: [
@@ -643,6 +697,9 @@ function getCreateDeviceInstruction(input) {
643697
if (!accounts.ataProgram.value) {
644698
accounts.ataProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
645699
}
700+
if (!accounts.payer.value) {
701+
accounts.payer.value = expectSome(accounts.vendor.value);
702+
}
646703
const getAccountMeta = getAccountMetaFactory(programAddress);
647704
const instruction = {
648705
accounts: [
@@ -824,6 +881,9 @@ function getInitializeInstruction(input) {
824881
if (!accounts.systemProgram.value) {
825882
accounts.systemProgram.value = "11111111111111111111111111111111";
826883
}
884+
if (!accounts.payer.value) {
885+
accounts.payer.value = expectSome(accounts.authority.value);
886+
}
827887
const getAccountMeta = getAccountMetaFactory(programAddress);
828888
const instruction = {
829889
accounts: [
@@ -861,6 +921,6 @@ function parseInitializeInstruction(instruction) {
861921
};
862922
}
863923

864-
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 };
924+
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 };
865925
//# sourceMappingURL=out.js.map
866926
//# sourceMappingURL=index.mjs.map

clients/js/dist/src/index.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)