Skip to content

Commit b530a54

Browse files
authored
Add valueLTE caveat to erc20 streaming permission (#103)
1 parent 1118b53 commit b530a54

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

packages/gator-permissions-snap/snap.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/MetaMask/snap-7715-permissions.git"
88
},
99
"source": {
10-
"shasum": "WwTyuE9UTnU+xFxt6WVlQLQIniNRtMZSXEyvV0G0dm0=",
10+
"shasum": "LVsPU3JPEZJPby8z8oSovpKVsA91x6sheko2alRExeU=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

packages/gator-permissions-snap/src/permissions/erc20TokenStream/caveats.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ export async function appendCaveats({
1919
const { initialAmount, maxAmount, amountPerSecond, startTime } =
2020
permission.data;
2121

22-
caveatBuilder.addCaveat(
23-
'erc20Streaming',
24-
permission.data.tokenAddress,
25-
BigInt(initialAmount),
26-
BigInt(maxAmount),
27-
BigInt(amountPerSecond),
28-
startTime,
29-
);
22+
caveatBuilder
23+
.addCaveat(
24+
'erc20Streaming',
25+
permission.data.tokenAddress,
26+
BigInt(initialAmount),
27+
BigInt(maxAmount),
28+
BigInt(amountPerSecond),
29+
startTime,
30+
)
31+
.addCaveat('valueLte', 0n);
3032

3133
return caveatBuilder;
3234
}

packages/gator-permissions-snap/test/permissions/erc20TokenStream/caveats.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ describe('erc20TokenStream:caveats', () => {
4747
startTime,
4848
);
4949

50-
expect(mockCaveatBuilder.addCaveat).toHaveBeenCalledTimes(1);
50+
expect(mockCaveatBuilder.addCaveat).toHaveBeenCalledWith('valueLte', 0n);
51+
52+
expect(mockCaveatBuilder.addCaveat).toHaveBeenCalledTimes(2);
5153
});
5254

5355
it('should return the modified caveat builder', async () => {

0 commit comments

Comments
 (0)