Skip to content

Commit 677b049

Browse files
feat: Add Intl as a default endowment (#3035)
Add `Intl` as a default endowment to allow Snaps to use the browser native functionality for formatting text and numbers in the UI. Closes #3034
1 parent 78dd810 commit 677b049

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

packages/snaps-execution-environments/src/common/endowments/commonEndowmentFactory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const commonEndowments: CommonEndowmentSpecification[] = [
3939
{ endowment: DataView, name: 'DataView' },
4040
{ endowment: Float32Array, name: 'Float32Array' },
4141
{ endowment: Float64Array, name: 'Float64Array' },
42+
{ endowment: Intl, name: 'Intl' },
4243
{ endowment: Int8Array, name: 'Int8Array' },
4344
{ endowment: Int16Array, name: 'Int16Array' },
4445
{ endowment: Int32Array, name: 'Int32Array' },

packages/snaps-execution-environments/src/common/endowments/endowments.test.browser.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ describe('endowments', () => {
168168
endowments: { crypto },
169169
factory: () => crypto,
170170
},
171+
Intl: {
172+
endowments: { Intl },
173+
factory: () => Intl,
174+
},
171175
mathAttenuated: {
172176
endowments: { mathAttenuated },
173177
factory: () => mathAttenuated,
@@ -352,6 +356,10 @@ describe('endowments', () => {
352356
factory: expect.any(Function),
353357
names: ['Float64Array'],
354358
},
359+
{
360+
factory: expect.any(Function),
361+
names: ['Intl'],
362+
},
355363
{
356364
factory: expect.any(Function),
357365
names: ['Int8Array'],

packages/snaps-simulation/src/methods/specifications.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ describe('getEndowments', () => {
356356
"Uint16Array",
357357
"Int32Array",
358358
"isSecureContext",
359+
"Intl",
359360
"Uint32Array",
360361
"Float32Array",
361362
"Float64Array",

packages/snaps-utils/src/default-endowments.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const DEFAULT_ENDOWMENTS: readonly string[] = Object.freeze([
2424
'Uint16Array',
2525
'Int32Array',
2626
'isSecureContext',
27+
'Intl',
2728
'Uint32Array',
2829
'Float32Array',
2930
'Float64Array',

0 commit comments

Comments
 (0)