Skip to content

Commit c97fde5

Browse files
hyeonmin Songhyeonmin Song
authored andcommitted
integration fixed, WIP: one still fails due to the airdrop issue
1 parent a4fb6dd commit c97fde5

23 files changed

Lines changed: 85 additions & 1386 deletions

client/src/api/abstractCryptid.ts

Lines changed: 18 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import { Signer } from '../types/crypto';
22
import { PublicKey, Transaction, TransactionSignature } from '@solana/web3.js';
33
import { Cryptid, CryptidOptions, DEFAULT_CRYPTID_OPTIONS } from './cryptid';
4-
import { addKey as addKeyTransaction } from '../lib/solana/transactions/did/addKey';
5-
import { removeKey as removeKeyTransaction } from '../lib/solana/transactions/did/removeKey';
6-
import { addService as addServiceTransaction } from '../lib/solana/transactions/did/addService';
7-
import { removeService as removeServiceTransaction } from '../lib/solana/transactions/did/removeService';
8-
import { addController as addControllerTransaction } from '../lib/solana/transactions/did/addController';
9-
import { removeController as removeControllerTransaction } from '../lib/solana/transactions/did/removeController';
10-
import { DIDDocument, ServiceEndpoint } from 'did-resolver';
4+
// import { addKey as addKeyTransaction } from '../lib/solana/transactions/did/addKey';
5+
import { DIDDocument } from 'did-resolver';
116
import { DidSolIdentifier, DidSolService } from '@identity.com/sol-did-client';
127
import { didToDefaultDOASigner } from '../lib/util';
138
import { CRYPTID_PROGRAM_ID } from '../lib/constants';
@@ -96,97 +91,22 @@ export abstract class AbstractCryptid implements Cryptid {
9691
}
9792
}
9893

99-
async addKey(
100-
publicKey: PublicKey,
101-
alias: string
102-
): Promise<TransactionSignature> {
103-
const signer = await this.getSignerForInternalTransaction();
104-
const authority = await this.signer.publicKey;
105-
const transaction = await addKeyTransaction(
106-
this.options.connection,
107-
this.did,
108-
signer,
109-
publicKey,
110-
alias,
111-
authority
112-
);
113-
return this.send(transaction);
114-
}
115-
116-
async removeKey(alias: string): Promise<TransactionSignature> {
117-
const signer = await this.getSignerForInternalTransaction();
118-
const authority = await this.signer.publicKey;
119-
120-
const transaction = await removeKeyTransaction(
121-
this.options.connection,
122-
this.did,
123-
signer,
124-
alias,
125-
authority
126-
);
127-
128-
return this.send(transaction);
129-
}
130-
131-
async addService(service: ServiceEndpoint): Promise<TransactionSignature> {
132-
const signer = await this.getSignerForInternalTransaction();
133-
const authority = await this.signer.publicKey;
134-
135-
const transaction = await addServiceTransaction(
136-
this.options.connection,
137-
this.did,
138-
signer,
139-
service,
140-
authority
141-
);
142-
143-
return this.send(transaction);
144-
}
145-
146-
async removeService(alias: string): Promise<TransactionSignature> {
147-
const signer = await this.getSignerForInternalTransaction();
148-
const authority = await this.signer.publicKey;
149-
150-
const transaction = await removeServiceTransaction(
151-
this.options.connection,
152-
this.did,
153-
signer,
154-
alias,
155-
authority
156-
);
157-
158-
return this.send(transaction);
159-
}
160-
161-
async addController(controller: string): Promise<TransactionSignature> {
162-
const signer = await this.getSignerForInternalTransaction();
163-
const authority = await this.signer.publicKey;
164-
165-
const transaction = await addControllerTransaction(
166-
this.options.connection,
167-
this.did,
168-
signer,
169-
controller,
170-
authority
171-
);
172-
173-
return this.send(transaction);
174-
}
175-
176-
async removeController(controller: string): Promise<TransactionSignature> {
177-
const signer = await this.getSignerForInternalTransaction();
178-
const authority = await this.signer.publicKey;
179-
180-
const transaction = await removeControllerTransaction(
181-
this.options.connection,
182-
this.did,
183-
signer,
184-
controller,
185-
authority
186-
);
187-
188-
return this.send(transaction);
189-
}
94+
// async addKey(
95+
// publicKey: PublicKey,
96+
// alias: string
97+
// ): Promise<TransactionSignature> {
98+
// const signer = await this.getSignerForInternalTransaction();
99+
// const authority = await this.signer.publicKey;
100+
// const transaction = await addKeyTransaction(
101+
// this.options.connection,
102+
// this.did,
103+
// signer,
104+
// publicKey,
105+
// alias,
106+
// authority
107+
// );
108+
// return this.send(transaction);
109+
// }
190110

191111
// Base case for collecting all additional keys that must be provided when signing
192112
// a transaction with controller chains. Each controller layer adds an additional key here

client/src/api/cryptid.ts

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Transaction,
55
TransactionSignature,
66
} from '@solana/web3.js';
7-
import { DIDDocument, ServiceEndpoint } from 'did-resolver';
7+
import { DIDDocument } from 'did-resolver';
88
import { Signer } from '../types/crypto';
99
import { NonEmptyArray } from '../types/lang';
1010

@@ -56,42 +56,12 @@ export interface Cryptid {
5656

5757
cancelLarge(transactionAccount: PublicKey): Promise<TransactionSignature>;
5858

59-
/**
60-
* Adds a key to your the Crytid account
61-
* @param publicKey The public key to add
62-
* @param alias A unique alias for that key
63-
*/
64-
addKey(publicKey: PublicKey, alias: string): Promise<TransactionSignature>;
65-
66-
/**
67-
* Removes a key from the account
68-
* @param alias The alias of the key to remove
69-
*/
70-
removeKey(alias: string): Promise<TransactionSignature>;
71-
72-
/**
73-
* Adds a service to the Cryptid account instance
74-
* @param service The service to add
75-
*/
76-
addService(service: ServiceEndpoint): Promise<TransactionSignature>;
77-
78-
/**
79-
* Removes a service form the Cryptid account
80-
* @param alias The alias of the service to remove
81-
*/
82-
removeService(alias: string): Promise<TransactionSignature>;
83-
84-
/**
85-
* Adds a controller to the Cryptid account
86-
* @param did The DID of the controller to add
87-
*/
88-
addController(did: string): Promise<TransactionSignature>;
89-
90-
/**
91-
* Removes a controller from the Cryptis account
92-
* @param did The DID of the controller to remove
93-
*/
94-
removeController(did: string): Promise<TransactionSignature>;
59+
// /**
60+
// * Adds a key to your the Crytid account
61+
// * @param publicKey The public key to add
62+
// * @param alias A unique alias for that key
63+
// */
64+
// addKey(publicKey: PublicKey, alias: string): Promise<TransactionSignature>;
9565

9666
/**
9767
* Retrieves the DID document for this Cryptid account

client/src/lib/solana/transactions/did/addController.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

client/src/lib/solana/transactions/did/addKey.ts

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
1-
import { Connection, PublicKey, Transaction } from '@solana/web3.js';
2-
import { LegacyClient } from '@identity.com/sol-did-client'; // TODO: remove
3-
import { Signer } from '../../../../types/crypto';
4-
import { createTransaction } from '../util';
5-
import { filterNotNil } from '../../../util';
6-
import { DEFAULT_DID_DOCUMENT_SIZE } from '../../../constants';
1+
// import { Connection, PublicKey, Transaction } from '@solana/web3.js';
2+
// import { Signer } from '../../../../types/crypto';
3+
// import { createTransaction } from '../util';
4+
// import { filterNotNil } from '../../../util';
5+
// import { DEFAULT_DID_DOCUMENT_SIZE } from '../../../constants';
6+
// import { TransactionInstruction } from '@solana/web3.js';
7+
// import { AddKeyInstructionRequest} from '@identity.com/sol-did-client-legacy/dist/lib/util';
78

8-
/**
9-
* Creates a transaction that adds a key to a DID.
10-
*
11-
* This transaction will either contain a register instruction (if the DID is not yet registered on chain)
12-
* or an update instruction (if it is already registered), but not both
13-
*/
14-
export const addKey = async (
15-
connection: Connection,
16-
did: string,
17-
signer: Signer,
18-
newKey: PublicKey,
19-
alias: string,
20-
authority: PublicKey
21-
): Promise<Transaction> => {
22-
const instruction = await LegacyClient.createAddKeyInstruction({
23-
authority,
24-
did,
25-
key: newKey,
26-
fragment: alias,
27-
connection,
28-
payer: signer.publicKey,
29-
size: DEFAULT_DID_DOCUMENT_SIZE,
30-
});
9+
// /**
10+
// * Creates a transaction that adds a key to a DID.
11+
// *
12+
// * This transaction will either contain a register instruction (if the DID is not yet registered on chain)
13+
// * or an update instruction (if it is already registered), but not both
14+
// */
15+
// export const addKey = async (
16+
// connection: Connection,
17+
// did: string,
18+
// signer: Signer,
19+
// newKey: PublicKey,
20+
// alias: string,
21+
// authority: PublicKey
22+
// ): Promise<Transaction> => {
23+
// const instruction = await createAddKeyInstruction({
24+
// authority,
25+
// did,
26+
// key: newKey,
27+
// fragment: alias,
28+
// connection,
29+
// payer: signer.publicKey,
30+
// size: DEFAULT_DID_DOCUMENT_SIZE,
31+
// });
3132

32-
const recentBlockhash = (await connection.getRecentBlockhash()).blockhash;
33+
// const recentBlockhash = (await connection.getRecentBlockhash()).blockhash;
34+
35+
// return await createTransaction(
36+
// recentBlockhash,
37+
// filterNotNil([instruction]),
38+
// signer.publicKey,
39+
// [signer]
40+
// );
41+
// };
42+
43+
// export declare const createAddKeyInstruction: (request: AddKeyInstructionRequest) => Promise<TransactionInstruction>;
3344

34-
return await createTransaction(
35-
recentBlockhash,
36-
filterNotNil([instruction]),
37-
signer.publicKey,
38-
[signer]
39-
);
40-
};

client/src/lib/solana/transactions/did/addService.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

client/src/lib/solana/transactions/did/removeController.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)