@@ -16,11 +16,9 @@ import {
1616 sendAndConfirmCryptidTransaction ,
1717} from '../utils/solana' ;
1818import { publicKeyToDid } from '../../src/lib/solana/util' ;
19-
19+ import { DidSolIdentifier , DidSolService , VerificationMethodFlags , VerificationMethodType } from '@identity.com/sol-did-client' ;
2020const { expect } = chai ;
2121import chaiAsPromised from 'chai-as-promised' ;
22- // import { DidSolIdentifier, DidSolService } from "@identity.com/sol-did-client";
23- // import { METHODS } from 'http';
2422chai . use ( chaiAsPromised ) ;
2523
2624// needs to be less than AIRDROP_LAMPORTS
@@ -122,29 +120,34 @@ describe('transfers', function () {
122120 // expect(balances.for(recipient).to.equal(lamportsToTransfer);
123121 } ) ;
124122
125- it . skip ( 'should sign a transaction from a DID with a second key' , async ( ) => {
123+ it ( 'should sign a transaction from a DID with a second key' , async ( ) => {
126124 // the cryptid client for device 1 that will add the new key
127125 // const cryptidForDevice1 = cryptid;
128126
129127 // the new key that will be added to the DID
130128 const device2Key = Keypair . generate ( ) ;
131- // const alias = 'device2';
129+ const alias = 'device2' ;
132130
133131 // airdrop to device2 key to cover fees for the transfer only
134132 await airdrop ( connection , device2Key . publicKey , 10_000 ) ;
135133
136- // add the new key and create a cryptid client for device 2
137134 // await cryptidForDevice1.addKey(device2Key.publicKey, alias);
138135 // TODO: Challenge: Replace this with a did:sol library call for addKey
139- // const id = DidSolIdentifier.parse(cryptid.did);
140- // const service = await DidSolService.build(id);
141- // service.addVerificationMethod(...);
136+ const id = DidSolIdentifier . parse ( cryptid . did ) ;
137+ const service = await DidSolService . build ( id ) ;
138+ await service . addVerificationMethod ( {
139+ fragment : alias ,
140+ keyData : device2Key . publicKey . toBytes ( ) ,
141+ methodType : VerificationMethodType . Ed25519VerificationKey2018 ,
142+ flags : VerificationMethodFlags . CapabilityInvocation ,
143+ } ) . withPartialSigners ( key ) . rpc ( ) ;
144+
142145 const cryptidForDevice2 = await build ( did , device2Key , {
143146 connection,
144147 waitForConfirmation : true ,
145148 } ) ;
146149
147- //create a transfer and sign with cryptid for device 2
150+ // create a transfer and sign with cryptid for device 2
148151 const tx = await createTransferTransaction (
149152 connection ,
150153 cryptidAddress ,
@@ -235,6 +238,7 @@ describe('transfers', function () {
235238
236239 // add the controller to the controlled DID (this anchors the controlled DID)
237240 // await controlledCryptid.addController(did);
241+
238242 balances = await new Balances ( connection ) . register (
239243 cryptidAddress , // controller cryptid
240244 controlledCryptidAddress , // controlled cryptid
0 commit comments