Skip to content

Commit

Permalink
using devtools method for generating test vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyoontbd committed Jan 24, 2024
1 parent 1d9adfd commit 744976b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 124 deletions.
25 changes: 0 additions & 25 deletions packages/protocol/src/dev-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,6 @@ export type RfqOptions = {
receiver?: PortableDid
}


/**
* Options passed to {@link DevTools.createCredential}
* @beta
*/
export type CreateCredentialOptions = Omit<CreateJwtOptions, 'payload'> & {
/** the credential type (e.g. UniversityDegreeCredential) */
type: string
/** data to include in the credential */
data: Record<string, any>
}

/**
* Options passed to {@link DevTools.createJwt}
* @beta
*/
export type CreateJwtOptions = {
/** the thing to sign */
payload: any,
/** the JWT's subject (e.g. Alice's DID) */
subject: string
/** the JWT's issuer */
issuer: PortableDid
}

/**
* Utility functions for testing purposes
* @beta
Expand Down
102 changes: 3 additions & 99 deletions packages/protocol/tests/generate-test-vectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DidKeyMethod } from '@web5/dids'
import { VerifiableCredential } from '@web5/credentials'
import { Close, Message, Offering, Order, OrderStatus, Quote, Rfq } from '../src/main.js'
import { Close, DevTools, Message, Order, OrderStatus, Quote, Rfq } from '../src/main.js'
import fs from 'fs'

/**
Expand All @@ -15,83 +15,7 @@ type TestVector = {

const generateParseOfferingVector = async () => {
const did = await DidKeyMethod.create()
const offering = Offering.create({
metadata : { from: did.did },
data : {
description : 'Selling BTC for USD',
payinCurrency : {
currencyCode : 'USD',
maxAmount : '1000000.00'
},
payoutCurrency: {
currencyCode : 'BTC',
maxAmount : '99952611.00000'
},
payoutUnitsPerPayinUnit : '0.00003826',
payinMethods : [{
kind : 'DEBIT_CARD',
requiredPaymentDetails : {
$schema : 'http://json-schema.org/draft-07/schema',
type : 'object',
properties : {
cardNumber: {
type : 'string',
description : 'The 16-digit debit card number',
minLength : 16,
maxLength : 16
},
expiryDate: {
type : 'string',
description : 'The expiry date of the card in MM/YY format',
pattern : '^(0[1-9]|1[0-2])\\/([0-9]{2})$'
},
cardHolderName: {
type : 'string',
description : 'Name of the cardholder as it appears on the card'
},
cvv: {
type : 'string',
description : 'The 3-digit CVV code',
minLength : 3,
maxLength : 3
}
},
required : ['cardNumber', 'expiryDate', 'cardHolderName', 'cvv'],
additionalProperties : false
}
}],
payoutMethods: [{
kind : 'BTC_ADDRESS',
requiredPaymentDetails : {
$schema : 'http://json-schema.org/draft-07/schema',
type : 'object',
properties : {
btcAddress: {
type : 'string',
description : 'your Bitcoin wallet address'
}
},
required : ['btcAddress'],
additionalProperties : false
}
}],
requiredClaims: {
id : '7ce4004c-3c38-4853-968b-e411bafcd945',
input_descriptors : [{
id : 'bbdb9b7c-5754-4f46-b63b-590bada959e0',
constraints : {
fields: [{
path : ['$.type'],
filter : {
type : 'string',
const : 'YoloCredential'
}
}]
}
}]
}
}
})
const offering = DevTools.createOffering()

await offering.sign(did)

Expand All @@ -111,27 +35,7 @@ const generateParseQuoteVector = async () => {
from : did.did,
to : 'did:ex:pfi'
},
data: {
expiresAt : new Date().toISOString(),
payin : {
currencyCode : 'BTC',
amount : '0.01',
fee : '0.0001',
paymentInstruction : {
link : 'tbdex.io/example',
instruction : 'Fake instruction'
}
},
payout: {
currencyCode : 'USD',
amount : '1000.00',
paymentInstruction : {
link : 'tbdex.io/example',
instruction : 'Fake instruction'
}
},

}
data: DevTools.createQuoteData()
})
await quote.sign(did)

Expand Down

0 comments on commit 744976b

Please sign in to comment.