Skip to content

Commit b357b29

Browse files
committed
fix lavamoat policy and handle requested changes
1 parent 4238235 commit b357b29

File tree

13 files changed

+119
-13
lines changed

13 files changed

+119
-13
lines changed

packages/snaps-execution-environments/lavamoat/browserify/iframe/policy.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@
9999
"packages": {
100100
"@metamask/rpc-errors": true,
101101
"@metamask/snaps-sdk": true,
102+
"@metamask/snaps-utils>luxon": true,
102103
"@metamask/superstruct": true,
103104
"@metamask/utils": true
104105
}
105106
},
107+
"@metamask/snaps-utils>luxon": {
108+
"globals": {
109+
"Intl": true
110+
}
111+
},
106112
"@metamask/utils": {
107113
"globals": {
108114
"TextDecoder": true,

packages/snaps-execution-environments/lavamoat/browserify/node-process/policy.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,16 @@
109109
"packages": {
110110
"@metamask/rpc-errors": true,
111111
"@metamask/snaps-sdk": true,
112+
"@metamask/snaps-utils>luxon": true,
112113
"@metamask/superstruct": true,
113114
"@metamask/utils": true
114115
}
115116
},
117+
"@metamask/snaps-utils>luxon": {
118+
"globals": {
119+
"Intl": true
120+
}
121+
},
116122
"@metamask/utils": {
117123
"builtin": {
118124
"buffer.Buffer": true

packages/snaps-execution-environments/lavamoat/browserify/node-thread/policy.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,16 @@
109109
"packages": {
110110
"@metamask/rpc-errors": true,
111111
"@metamask/snaps-sdk": true,
112+
"@metamask/snaps-utils>luxon": true,
112113
"@metamask/superstruct": true,
113114
"@metamask/utils": true
114115
}
115116
},
117+
"@metamask/snaps-utils>luxon": {
118+
"globals": {
119+
"Intl": true
120+
}
121+
},
116122
"@metamask/utils": {
117123
"builtin": {
118124
"buffer.Buffer": true

packages/snaps-execution-environments/lavamoat/browserify/webview/policy.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@
9999
"packages": {
100100
"@metamask/rpc-errors": true,
101101
"@metamask/snaps-sdk": true,
102+
"@metamask/snaps-utils>luxon": true,
102103
"@metamask/superstruct": true,
103104
"@metamask/utils": true
104105
}
105106
},
107+
"@metamask/snaps-utils>luxon": {
108+
"globals": {
109+
"Intl": true
110+
}
111+
},
106112
"@metamask/utils": {
107113
"globals": {
108114
"TextDecoder": true,

packages/snaps-execution-environments/lavamoat/browserify/worker-executor/policy.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@
9999
"packages": {
100100
"@metamask/rpc-errors": true,
101101
"@metamask/snaps-sdk": true,
102+
"@metamask/snaps-utils>luxon": true,
102103
"@metamask/superstruct": true,
103104
"@metamask/utils": true
104105
}
105106
},
107+
"@metamask/snaps-utils>luxon": {
108+
"globals": {
109+
"Intl": true
110+
}
111+
},
106112
"@metamask/utils": {
107113
"globals": {
108114
"TextDecoder": true,

packages/snaps-execution-environments/lavamoat/browserify/worker-pool/policy.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,16 @@
4545
"packages": {
4646
"@metamask/rpc-errors": true,
4747
"@metamask/snaps-sdk": true,
48+
"@metamask/snaps-utils>luxon": true,
4849
"@metamask/superstruct": true,
4950
"@metamask/utils": true
5051
}
5152
},
53+
"@metamask/snaps-utils>luxon": {
54+
"globals": {
55+
"Intl": true
56+
}
57+
},
5258
"@metamask/utils": {
5359
"globals": {
5460
"TextDecoder": true,

packages/snaps-execution-environments/src/common/validation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ export type RequestArguments =
128128
* Asserts that the given value is a valid request arguments object.
129129
*
130130
* @param value - The value to validate.
131-
* @param requestArgumentsStruct - The struct to validate the value against.
131+
* @param struct - The struct to validate the value against.
132132
* @throws If the value is not a valid request arguments object.
133133
*/
134134
function assertRequestArguments<Type, Schema>(
135135
value: unknown,
136-
requestArgumentsStruct: Struct<Type, Schema>,
136+
struct: Struct<Type, Schema>,
137137
): asserts value is Struct<Type, Schema> {
138138
assertStruct(
139139
value,
140-
requestArgumentsStruct,
140+
struct,
141141
'Invalid request params',
142142
rpcErrors.invalidParams,
143143
);

packages/snaps-rpc-methods/src/endowments/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export const handlerEndowments: Record<HandlerType, string | null> = {
126126
[HandlerType.OnSettingsPage]: settingsPageEndowmentBuilder.targetName,
127127
[HandlerType.OnSignature]: signatureInsightEndowmentBuilder.targetName,
128128
[HandlerType.OnUserInput]: null,
129+
[HandlerType.OnAssetHistoricalPrice]: assetsEndowmentBuilder.targetName,
129130
[HandlerType.OnAssetsLookup]: assetsEndowmentBuilder.targetName,
130131
[HandlerType.OnAssetsConversion]: assetsEndowmentBuilder.targetName,
131132
[HandlerType.OnProtocolRequest]: protocolEndowmentBuilder.targetName,

packages/snaps-sdk/src/types/handlers/asset-historical-price.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type HistoricalPriceValue = [number, string];
88

99
/**
1010
* The historical price object.
11-
* The key is the time period as an ISO 8601 duration, the value is an array of historical price values.
11+
* The key is the time period as an ISO 8601 duration or the "all" string, the value is an array of historical price values.
1212
*/
1313
export type HistoricalPriceIntervals = {
1414
[key: string]: HistoricalPriceValue[];
@@ -42,7 +42,7 @@ export type OnAssetHistoricalPriceArguments = {
4242
};
4343

4444
/**
45-
* The `onAssetHistoricalPrice` handler. This is called by MetaMask when querying about historical price of an asset pair on specific chains.
45+
* The `onAssetHistoricalPrice` handler. This is called by MetaMask when querying about the historical price of an asset pair on a specific chain.
4646
*
4747
* @returns The historical price of the asset pair. See
4848
* {@link OnAssetHistoricalPriceResponse}.

packages/snaps-utils/coverage.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"branches": 99.75,
3-
"functions": 98.94,
4-
"lines": 98.55,
5-
"statements": 97.03
3+
"functions": 98.95,
4+
"lines": 98.56,
5+
"statements": 97.05
66
}

0 commit comments

Comments
 (0)