Skip to content

Commit

Permalink
Merge pull request #122 from bcnmy/fix/fundingIdUpdateFlow
Browse files Browse the repository at this point in the history
Added Flow for updating fundingId using public sdk
  • Loading branch information
arpan-jain authored Nov 28, 2023
2 parents e249ceb + 7a1e6db commit e548648
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
112 changes: 111 additions & 1 deletion docs/apireference/dashboardapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,117 @@ Usually, this occurs when incorrect apiKey is used or the address is not added
}
```

#### 6. Delete Smart Contract
#### 6. Update Sponsorship Paymaster Funding Wallet:

##### It is a 3-step process.
##### *1. Generate a message from biconomy servers, for the sponsorship paymaster.*
> ***GET Request***
URL: https://paymaster-dashboard-backend.prod.biconomy.io/api/v2/public/sdk/funding-message/{{paymasterId}}

Headers

| Param | Type | Description | Required |
| --------------- | --------------- | --------------- | --------------- |
| authToken | string | Token unique to every user account | Required |
| apiKey | string | API Key Associated with dApp | Required |

Responses

> ***200 OK***

```javascript
{
"statusCode": 200,
"message": "Funding message sent",
"data": {
"fundingMessage": "Timestamp: November 27, 2023, 5:05 PM\nWelcome to Biconomy! This request will connect your gas tank to our app. It will not trigger a blockchain transaction or incur any fees."
}
}
```

> ***401 Unauthorized***

```javascript
{
"statusCode": 401,
"message": "Auth token and API key is required in the headers"
}
```
##### *2. Sign the generated message using the private key of the EOA (Funding Wallet).*
##### *3. Send the request to biconomy to update the funding wallet address.*

> ***PATCH Request***
URL: https://paymaster-dashboard-backend.prod.biconomy.io//api/v2/public/sdk/paymaster

Parameters

Header

| Param | Type | Description | Required |
| --------------- | --------------- | --------------- | --------------- |
| authToken | string | Token unique to every user account | Required |
| apiKey | string | API Key Associated with dApp | Required |

Body

| Param | Type | Description | Required |
|-------------|--------|-------------------------------------------------------------| --------------- |
| paymasterId | string | Sponsorship Paymaster Id | Required |
| type | string | Method Name. <br/>Use "paymasterFundingId" here | Required |
| signature | string | Signature generated using private key of EOA | Required |
| address | string | Address of the EOA which is to be updated as funding wallet | Required |

Responses

> ***200 OK***

```javascript
{
"statusCode": 200,
"message": "Paymaster updated successfully",
"data": {
"name": "testXXX",
"chainId": 80001,
"apiKey": "GwfDKydYq.2967f140-XXXX-4042-XXXX-76684f9XXXX",
"paymasterId": "e998530d-XXXX-451e-XXXX-cb6fXXXXef54"
}
}
```
> ***400 Bad Request***
This happens, when there is a signature mismatch, either because an older message is used to generate the signature, or EOA address mentioned in the request body, is not the address which signed the message.
```javascript
{
"statusCode": 400,
"message": "Invalid signature"
}
```
> ***401 Unauthorized***

```javascript
{
"statusCode": 401,
"message": "Auth token and API key is required in the headers"
}
```
> ***404 Not Found***
Usually, this occurs when incorrect apiKey or authToken is used
```javascript
{
"statusCode": 404,
"message": "User not found"
}
```


#### 7. Delete Smart Contract

> ***DELETE Request***
Expand Down
6 changes: 3 additions & 3 deletions docs/apireference/webhookapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ Our backend expects a response in this format:

const webhookResponseData = response.data;
this.logger.log(`webhookResponseData: ${JSON.stringify(webhookResponseData)} for dappId: ${dappId}`);
const { arePoliciesVerifed } = webhookResponseData;
const { arePoliciesVerified } = webhookResponseData;

```
`arePoliciesVerified` should either be true or false based on which it gets determined if the webhook conditions are passed or not.
Expand All @@ -307,11 +307,11 @@ app.post('/', (req, res) => {

if(num%2 === 0) {
res.json({
arePoliciesVerifed: true
arePoliciesVerified: true
})
} else {
res.json({
arePoliciesVerifed: false
arePoliciesVerified: false
})
}
});
Expand Down

0 comments on commit e548648

Please sign in to comment.