0.1.12 • Published 11 months ago

demoy-sdk v0.1.12

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Saasy SDK Documentation

This documentation provides a comprehensive guide to using the provided Saasy SDK. The SDK includes several functions for interacting with the agreement notary system. Each function is described below, along with their input parameters and return types.

Constructor

constructor(apiKey: string, _signer: Signer, _chainId: number, _paymaster?: string)

Creates an instance of the SDK.

Parameters:

  • apiKey: string - The API key to be used for making requests.
  • signer: Signer - The signer object for signing transactions.
  • chainId: number - The chain ID associated with the transactions.
  • paymaster: string (optional) - The address of the paymaster. If not provided, a default paymaster address is used.

Here's an example of how to initialize the SDK in a Node.js application:

const sdk = new SaaSySDK(API_KEY, SIGNER, CHAIN_ID);

In this example, API_KEY is your API key, SIGNER is your signer object, and CHAIN_ID is the chain ID you wish to use. If you want to specify a paymaster, you can pass it as the fourth parameter to the constructor.

getWalletAddress()

getWalletAddress(): Promise<string>

Returns the wallet address associated with the signer.

Parameters: None.

Returns: A Promise that resolves with the wallet address as a string.

isRegistryInit()

isRegistryInit(): boolean

Checks if the registry is initialized.

Parameters: None.

Returns: A boolean value indicating whether the registry is initialized or not.

initializeGSN()

initializeGSN(): Promise<void>

Initializes the Gas Station Network (GSN) by creating a GSN provider and initializing the registry contract.

Parameters: None.

Returns: A Promise that resolves with void. It throws an Error if there is an issue initializing the GSN.

getChallengeMessage()

getChallengeMessage(): Promise<string | any>

Retrieves the challenge message from the notary.

Parameters: None.

Returns: A Promise that resolves with the challenge message as a string, or an error object if an error occurs.

verify()

verify(): Promise<boolean>

Verifies the user's authentication by sending the signed challenge message and signature to the notary.

Parameters: None.

Returns: A Promise that resolves with a boolean indicating whether the verification was successful.

getTerms()

getTerms(termsContractAddress:0x${string}[]): Promise<TermResponse[]>

Retrieves the terms for the specified contract addresses from the notary service.

Parameters:

  • termsContractAddress: 0x${string}[] - An array of contract addresses to retrieve the terms for.

Returns: A Promise that resolves with an array of TermResponse objects containing the terms for each contract address. It throws an Error if there is an error retrieving the terms.

pinJSON()

pinJSON(toPin: object): Promise<PinResponse>

Pins a JSON object by sending it to the pinning service.

Parameters:

  • toPin: object - The JSON object to be pinned.

Returns: A Promise that resolves with the PinResponse object containing information about the pinned data. It throws an Error if there is an error pinning the data.

getPinnedData()

getPinnedData(ipfsHash: string): Promise<any>

Retrieves the pinned data associated with the given IPFS hash from the pinning service.

Parameters:

  • ipfsHash: string - The IPFS hash of the pinned data to retrieve.

Returns: A Promise that resolves with the pinned data retrieved from the pinning service. It throws an Error if there is an error retrieving the pinned data.

pinDynamicData()

pinDynamicData(data: DynamicData): Promise<PinResponse>

Pins dynamic data by sending it to the pinning service.

Parameters:

  • data: DynamicData - The dynamic data to be pinned.

Returns: A Promise that resolves with the PinResponse object containing information about the pinned data. It throws an Error if there is an error pinning the data or if the EXPIRATION_DATE field has an invalid format.

getExpectedAgreementHash()

getExpectedAgreementHash(agreementData: OnchainAgreement): Promise<string | undefined>

Retrieves the expected agreement hash for the given on-chain agreement data from the registry contract.

Parameters:

  • agreementData: OnchainAgreement - The on-chain agreement data.

Returns: A Promise that resolves with the expected agreement hash as a string, or undefined if an error occurs. It throws an Error if there is an error getting the expected agreement hash.

createAgreement()

createAgreement(agreementData: OnchainAgreement): Promise<CreatedAgreementData>

Creates a new agreement by sending the agreement data to the notary.

Parameters:

  • agreementData: OnchainAgreement - The agreement data.

Returns: A Promise that resolves with the created agreement data. It throws an Error if there is an error creating the agreement.

getPDFBytes()

getPDFBytes(agreementHash: string): Promise<Uint8Array>

Retrieves the PDF bytes associated with the given agreement hash from the file service.

Parameters:

  • agreementHash: string - The agreement hash.

Returns: A Promise that resolves with the PDF bytes as a Uint8Array. It throws an Error if there is an error getting the PDF bytes.

getAgreements()

getAgreements(searchCriteria: SearchAgreements): Promise<AgreementDataWithHash[]>

Retrieves a list of agreements based on the provided search criteria.

Parameters:

  • searchCriteria: SearchAgreements - The search criteria for filtering the agreements.

Returns: A Promise that resolves with an array of AgreementDataWithHash objects representing the agreements. It throws an Error if there is an error retrieving the agreements.

counterSignAgreement()

counterSignAgreement(countersignAgreementData: CounterSignAgreementData): Promise<Agreement>

Performs the counter-signing of an agreement by sending the countersign agreement data to the notary and updating the agreement on-chain.

Parameters:

  • countersignAgreementData: CounterSignAgreementData - The countersign agreement data.

Returns: A Promise that resolves with the updated Agreement object. It throws an Error if there is an error counter-signing the agreement or initializing GSN.

updateOfferer()

updateOfferer(updateOfferer: UpdateOfferer): Promise<UpdateOffererResponse>

Updates the offerer of an agreement by sending the update offerer data to the notary and updating the agreement on-chain.

Parameters:

  • updateOfferer: UpdateOfferer - The update offerer data.

Returns: A Promise that resolves with the UpdateOfferResponse object containing the updated promisor information. It throws an Error if there is an error updating the promisor or initializing GSN.

addTerm()

addTerm(terms: AddTerm): Promise<AddTermResponse>

Adds a term to an agreement by sending the add term data to the notary service and updating the agreement on-chain.

Parameters:

  • terms: AddTerm - The add term data.

Returns: A Promise that resolves with the AddTermResponse object containing the updated agreement information. It throws an Error if there is an error adding the term or initializing GSN.

removeTerm()

removeTerm(removeTermData: RemoveTermData): Promise<RemoveTermResponse>

Removes a term from an agreement by sending the remove term data to the notary service and updating the agreement on-chain.

Parameters:

  • removeTermData: RemoveTermData - The remove term data.

Returns: A Promise that resolves with the RemoveTermResponse object containing the updated agreement information. It throws an Error if there is an error removing the term or initializing GSN.

isAgreementValid()

isAgreementValid(agreementHash: string): Promise<boolean>

Checks the validity of an agreement by sending the agreement hash to the notary service for validation.

Parameters:

  • agreementHash: string - The hash of the agreement to be validated.

Returns: A Promise that resolves with a boolean indicating whether the agreement is valid or not. It throws an Error if there is an error checking the agreement validity.

cancelUserTransaction()

cancelUserTransaction(nonce: string): Promise<boolean>

Cancels a user transaction by burning the nonce associated with the transaction on-chain.

Parameters:

  • nonce: string - The nonce of the transaction to be cancelled.

Returns: A Promise that resolves with a boolean indicating whether the transaction was successfully cancelled or not. It throws an Error if there is an error cancelling the transaction or initializing GSN.

getAmountOwedNow()

getAmountOwedNow(agreementHash: string): Promise<AmountOwedNow>

Retrieves the amount currently owed for a specific agreement by querying the validator module and the associated payment token.

Parameters:

  • agreementHash: string - The hash of the agreement.

Returns: A Promise that resolves with an AmountOwedNow object containing the agreement hash, amount owed, and payment token address. It throws an Error if there is an error getting the amount owed now or retrieving the agreement.

0.1.12

11 months ago

0.1.11

12 months ago

0.1.10

12 months ago

0.1.9

12 months ago

0.1.8

12 months ago

0.1.7

12 months ago

0.1.6

12 months ago

0.1.5

12 months ago

0.1.4

12 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago